[#50] Makefile: Add code formatting targets

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-11-07 15:00:02 +03:00
parent 6e9c770142
commit dacac0b53d
18 changed files with 88 additions and 87 deletions

View file

@ -64,6 +64,18 @@ generate-wrappers: build $(foreach sc,$(all_sc),generate-wrapper.$(sc))
test: test:
@go test ./tests/... @go test ./tests/...
# Run all code formatters
fmts: fumpt imports
# Reformat imports
imports:
@echo "⇒ Processing goimports check"
@goimports -w $(all_sc) tests/
fumpt:
@echo "⇒ Processing gofumpt check"
@gofumpt -l -w $(all_sc) tests/
clean: clean:
find . -name '*.nef' -exec rm -rf {} \; find . -name '*.nef' -exec rm -rf {} \;
find . -name 'config.json' -exec rm -rf {} \; find . -name 'config.json' -exec rm -rf {} \;

View file

@ -27,6 +27,5 @@ Alphabet contract does not produce notifications to process.
| `name` | string | assigned glagolitic letter | | `name` | string | assigned glagolitic letter |
| `index` | int | the index of deployed alphabet contract | | `index` | int | the index of deployed alphabet contract |
| `threshold` | int | the total number of deployed alphabet contracts | | `threshold` | int | the total number of deployed alphabet contracts |
*/ */
package alphabet package alphabet

View file

@ -25,6 +25,5 @@ Audit contract does not produce notifications to process.
|--------------------|------------|-----------------------------------------------------------| |--------------------|------------|-----------------------------------------------------------|
| `netmapScriptHash` | Hash160 | netmap contract hash | | `netmapScriptHash` | Hash160 | netmap contract hash |
| auditID | ByteArray | serialized DataAuditResult structure | | auditID | ByteArray | serialized DataAuditResult structure |
*/ */
package audit package audit

View file

@ -330,9 +330,7 @@ func (t Token) transfer(ctx storage.Context, from, to interop.Hash160, amount in
// canTransfer returns the amount it can transfer. // canTransfer returns the amount it can transfer.
func (t Token) canTransfer(ctx storage.Context, from, to interop.Hash160, amount int, innerRing bool) (Account, bool) { func (t Token) canTransfer(ctx storage.Context, from, to interop.Hash160, amount int, innerRing bool) (Account, bool) {
var ( emptyAcc := Account{}
emptyAcc = Account{}
)
if !innerRing { if !innerRing {
if len(to) != interop.Hash160Len || !isUsableAddress(from) { if len(to) != interop.Hash160Len || !isUsableAddress(from) {

View file

@ -82,6 +82,5 @@ when FrostFS contract has transferred GAS assets back to the user.
| `netmapScriptHash` | Hash160 | netmap contract hash | | `netmapScriptHash` | Hash160 | netmap contract hash |
| `containerScriptHash` | Hash160 | container contract hash | | `containerScriptHash` | Hash160 | container contract hash |
| circulationKey | int | the token circulation key value | | circulationKey | int | the token circulation key value |
*/ */
package balance package balance

View file

@ -82,9 +82,7 @@ const (
defaultTTL = 3600 // 1 hour defaultTTL = 3600 // 1 hour
) )
var ( var eACLPrefix = []byte("eACL")
eACLPrefix = []byte("eACL")
)
// OnNEP11Payment is needed for registration with contract as the owner to work. // OnNEP11Payment is needed for registration with contract as the owner to work.
func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) { func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) {
@ -187,7 +185,8 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
// Note that zone must exist. // Note that zone must exist.
func PutNamed(container []byte, signature interop.Signature, func PutNamed(container []byte, signature interop.Signature,
publicKey interop.PublicKey, token []byte, publicKey interop.PublicKey, token []byte,
name, zone string) { name, zone string,
) {
ctx := storage.GetContext() ctx := storage.GetContext()
ownerID := ownerFromBinaryContainer(container) ownerID := ownerFromBinaryContainer(container)

View file

@ -38,7 +38,5 @@ it in Container contract.
| `o` + ownerID + containerID | ByteArray | container ID | | `o` + ownerID + containerID | ByteArray | container ID |
| `x` + containerID | ByteArray | serialized container struct | | `x` + containerID | ByteArray | serialized container struct |
| `nnsHasAlias` + containerID | string | domain name | | `nnsHasAlias` + containerID | string | domain name |
*/ */
package container package container

View file

@ -88,7 +88,5 @@ FrostFS network configuration value.
| `processingScriptHash` | Hash160 | processing contract hash | | `processingScriptHash` | Hash160 | processing contract hash |
| `candidates` + candidateKey | ByteArray | it flags inner ring candidate | | `candidates` + candidateKey | ByteArray | it flags inner ring candidate |
| `config` + postfix | ByteArray | serialized config data | | `config` + postfix | ByteArray | serialized config data |
*/ */
package frostfs package frostfs

View file

@ -38,9 +38,7 @@ const (
ignoreDepositNotification = "\x57\x0b" ignoreDepositNotification = "\x57\x0b"
) )
var ( var configPrefix = []byte("config")
configPrefix = []byte("config")
)
// _deploy sets up initial alphabet node keys. // _deploy sets up initial alphabet node keys.
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {

View file

@ -24,6 +24,5 @@ FrostFSID contract does not produce notifications to process.
| `processingScriptHash` | Hash160 | netmap contract hash | | `processingScriptHash` | Hash160 | netmap contract hash |
| `containerScriptHash` | Hash160 | container contract hash | | `containerScriptHash` | Hash160 | container contract hash |
| `o` + ownerID + publicKey | ByteArray | it flags owner's public key | | `o` + ownerID + publicKey | ByteArray | it flags owner's public key |
*/ */
package frostfsid package frostfsid

View file

@ -41,6 +41,5 @@ in the network by invoking NewEpoch method.
| `snapshotCurrent` | int | current snapshot | | `snapshotCurrent` | int | current snapshot |
| `balanceScriptHash` | Hash160 | balance contract hash | | `balanceScriptHash` | Hash160 | balance contract hash |
| `containerScriptHash` | Hash160 | container contract hash | | `containerScriptHash` | Hash160 | container contract hash |
*/ */
package netmap package netmap

View file

@ -69,7 +69,7 @@ var (
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
var args = data.(struct { args := data.(struct {
addrBalance interop.Hash160 addrBalance interop.Hash160
addrContainer interop.Hash160 addrContainer interop.Hash160
keys []interop.PublicKey keys []interop.PublicKey

View file

@ -24,6 +24,5 @@ Processing contract does not produce notifications to process.
| Key | Value | Description | | Key | Value | Description |
|-----------------------------|------------|----------------------------------| |-----------------------------|------------|----------------------------------|
| `frostfsScriptHash` | Hash160 | frostFS contract hash | | `frostfsScriptHash` | Hash160 | frostFS contract hash |
*/ */
package processing package processing

View file

@ -21,6 +21,5 @@ Proxy contract does not produce notifications to process.
# Contract storage scheme # Contract storage scheme
Proxy contract does not use storage Proxy contract does not use storage
*/ */
package proxy package proxy

View file

@ -20,6 +20,5 @@ Reputation contract does not produce notifications to process.
|-----------------------------|------------|-----------------------------------| |-----------------------------|------------|-----------------------------------|
| `c` + epoch + peerID | int | peer reputation count | | `c` + epoch + peerID | int | peer reputation count |
| `r` + count | ByteArray | serialized DataAuditResult struct | | `r` + count | ByteArray | serialized DataAuditResult struct |
*/ */
package reputation package reputation

View file

@ -24,8 +24,8 @@ import (
const containerPath = "../container" const containerPath = "../container"
const ( const (
containerFee = 0_0100_0000 containerFee = 0o_0100_0000
containerAliasFee = 0_0050_0000 containerAliasFee = 0o_0050_0000
) )
func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 { func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 {
@ -163,7 +163,6 @@ func checkContainerList(t *testing.T, c *neotest.ContractInvoker, expected [][]b
} }
require.ElementsMatch(t, expected, actual) require.ElementsMatch(t, expected, actual)
}) })
} }
func TestContainerPut(t *testing.T) { func TestContainerPut(t *testing.T) {
@ -228,7 +227,8 @@ func TestContainerPut(t *testing.T) {
c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...) c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...)
expected = stackitem.NewArray([]stackitem.Item{ expected = stackitem.NewArray([]stackitem.Item{
stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:])))}) stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:]))),
})
cNNS.Invoke(t, expected, "resolve", "domain.cdn", int64(nns.TXT)) cNNS.Invoke(t, expected, "resolve", "domain.cdn", int64(nns.TXT))
}) })
}) })

View file

@ -21,7 +21,8 @@ import (
const frostfsPath = "../frostfs" const frostfsPath = "../frostfs"
func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160, func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160,
pubs keys.PublicKeys, config ...interface{}) util.Uint160 { pubs keys.PublicKeys, config ...interface{},
) util.Uint160 {
args := make([]interface{}, 3) args := make([]interface{}, 3)
args[0] = addrProc args[0] = addrProc

View file

@ -115,7 +115,8 @@ func TestNNSRegister(t *testing.T) {
expected = stackitem.NewArray([]stackitem.Item{ expected = stackitem.NewArray([]stackitem.Item{
stackitem.NewByteArray([]byte("first TXT record")), stackitem.NewByteArray([]byte("first TXT record")),
stackitem.NewByteArray([]byte("second TXT record"))}) stackitem.NewByteArray([]byte("second TXT record")),
})
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT)) c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
cAcc.Invoke(t, stackitem.Null{}, "setRecord", cAcc.Invoke(t, stackitem.Null{}, "setRecord",
@ -123,7 +124,8 @@ func TestNNSRegister(t *testing.T) {
expected = stackitem.NewArray([]stackitem.Item{ expected = stackitem.NewArray([]stackitem.Item{
stackitem.NewByteArray([]byte("replaced first")), stackitem.NewByteArray([]byte("replaced first")),
stackitem.NewByteArray([]byte("second TXT record"))}) stackitem.NewByteArray([]byte("second TXT record")),
})
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT)) c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
} }
@ -185,7 +187,8 @@ func TestNNSRegisterMulti(t *testing.T) {
c2.Invoke(t, stackitem.Null{}, "addRecord", c2.Invoke(t, stackitem.Null{}, "addRecord",
"cdn.mainnet.fs.neo.com", int64(nns.A), "166.15.14.13") "cdn.mainnet.fs.neo.com", int64(nns.A), "166.15.14.13")
result := stackitem.NewArray([]stackitem.Item{ result := stackitem.NewArray([]stackitem.Item{
stackitem.NewByteArray([]byte("166.15.14.13"))}) stackitem.NewByteArray([]byte("166.15.14.13")),
})
c2.Invoke(t, result, "resolve", "cdn.mainnet.fs.neo.com", int64(nns.A)) c2.Invoke(t, result, "resolve", "cdn.mainnet.fs.neo.com", int64(nns.A))
} }
@ -262,7 +265,8 @@ func TestExpiration(t *testing.T) {
checkProperties := func(t *testing.T, expiration uint64) { checkProperties := func(t *testing.T, expiration uint64) {
expected := stackitem.NewMapWithValue([]stackitem.MapElement{ expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")}, {Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)}}) {Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)},
})
s, err := c.TestInvoke(t, "properties", "testdomain.com") s, err := c.TestInvoke(t, "properties", "testdomain.com")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, expected.Value(), s.Top().Item().Value()) require.Equal(t, expected.Value(), s.Top().Item().Value())
@ -351,7 +355,8 @@ func TestNNSRenew(t *testing.T) {
c1.Invoke(t, ts, "renew", "testdomain.com") c1.Invoke(t, ts, "renew", "testdomain.com")
expected := stackitem.NewMapWithValue([]stackitem.MapElement{ expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")}, {Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)}}) {Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)},
})
cAcc.Invoke(t, expected, "properties", "testdomain.com") cAcc.Invoke(t, expected, "properties", "testdomain.com")
} }