[#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:
@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:
find . -name '*.nef' -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 |
| `index` | int | the index of deployed alphabet contract |
| `threshold` | int | the total number of deployed alphabet contracts |
*/
package alphabet

View file

@ -25,6 +25,5 @@ Audit contract does not produce notifications to process.
|--------------------|------------|-----------------------------------------------------------|
| `netmapScriptHash` | Hash160 | netmap contract hash |
| auditID | ByteArray | serialized DataAuditResult structure |
*/
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.
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 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 |
| `containerScriptHash` | Hash160 | container contract hash |
| circulationKey | int | the token circulation key value |
*/
package balance

View file

@ -82,9 +82,7 @@ const (
defaultTTL = 3600 // 1 hour
)
var (
eACLPrefix = []byte("eACL")
)
var eACLPrefix = []byte("eACL")
// OnNEP11Payment is needed for registration with contract as the owner to work.
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.
func PutNamed(container []byte, signature interop.Signature,
publicKey interop.PublicKey, token []byte,
name, zone string) {
name, zone string,
) {
ctx := storage.GetContext()
ownerID := ownerFromBinaryContainer(container)

View file

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

View file

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

View file

@ -38,9 +38,7 @@ const (
ignoreDepositNotification = "\x57\x0b"
)
var (
configPrefix = []byte("config")
)
var configPrefix = []byte("config")
// _deploy sets up initial alphabet node keys.
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 |
| `containerScriptHash` | Hash160 | container contract hash |
| `o` + ownerID + publicKey | ByteArray | it flags owner's public key |
*/
package frostfsid

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -24,8 +24,8 @@ import (
const containerPath = "../container"
const (
containerFee = 0_0100_0000
containerAliasFee = 0_0050_0000
containerFee = 0o_0100_0000
containerAliasFee = 0o_0050_0000
)
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)
})
}
func TestContainerPut(t *testing.T) {
@ -228,7 +227,8 @@ func TestContainerPut(t *testing.T) {
c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...)
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))
})
})

View file

@ -21,7 +21,8 @@ import (
const frostfsPath = "../frostfs"
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[0] = addrProc

View file

@ -115,7 +115,8 @@ func TestNNSRegister(t *testing.T) {
expected = stackitem.NewArray([]stackitem.Item{
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))
cAcc.Invoke(t, stackitem.Null{}, "setRecord",
@ -123,7 +124,8 @@ func TestNNSRegister(t *testing.T) {
expected = stackitem.NewArray([]stackitem.Item{
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))
}
@ -185,7 +187,8 @@ func TestNNSRegisterMulti(t *testing.T) {
c2.Invoke(t, stackitem.Null{}, "addRecord",
"cdn.mainnet.fs.neo.com", int64(nns.A), "166.15.14.13")
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))
}
@ -262,7 +265,8 @@ func TestExpiration(t *testing.T) {
checkProperties := func(t *testing.T, expiration uint64) {
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{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")
require.NoError(t, err)
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")
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{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")
}