From d890a7eba49f2076f0e77480b43a76d384e99118 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 7 Nov 2023 15:18:48 +0300 Subject: [PATCH] [#50] Replace `interface{}` with `any` Signed-off-by: Evgenii Stratonikov --- alphabet/alphabet_contract.go | 8 ++++---- audit/audit_contract.go | 16 ++++++++-------- balance/balance_contract.go | 12 ++++++------ common/storage.go | 2 +- common/transfer.go | 2 +- common/version.go | 6 +++--- container/container_contract.go | 18 +++++++++--------- frostfs/frostfs_contract.go | 14 +++++++------- frostfsid/frostfsid_contract.go | 8 ++++---- netmap/netmap_contract.go | 10 +++++----- nns/nns_contract.go | 14 +++++++------- policy/policy_contract.go | 2 +- processing/processing_contract.go | 8 ++++---- proxy/proxy_contract.go | 8 ++++---- reputation/reputation_contract.go | 8 ++++---- tests/alphabet_test.go | 10 +++++----- tests/balance_test.go | 2 +- tests/container_test.go | 14 +++++++------- tests/frostfs_test.go | 10 +++++----- tests/frostfsid_test.go | 14 +++++++------- tests/netmap_test.go | 10 +++++----- tests/nns_test.go | 4 ++-- tests/processing_test.go | 2 +- tests/proxy_test.go | 2 +- tests/reputation_test.go | 2 +- 25 files changed, 103 insertions(+), 103 deletions(-) diff --git a/alphabet/alphabet_contract.go b/alphabet/alphabet_contract.go index c8530b3..af7540b 100644 --- a/alphabet/alphabet_contract.go +++ b/alphabet/alphabet_contract.go @@ -22,18 +22,18 @@ const ( // OnNEP17Payment is a callback for NEP-17 compatible native GAS and NEO // contracts. -func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { +func OnNEP17Payment(from interop.Hash160, amount int, data any) { caller := runtime.GetCallingScriptHash() if !common.BytesEqual(caller, []byte(gas.Hash)) && !common.BytesEqual(caller, []byte(neo.Hash)) { common.AbortWithMessage("alphabet contract accepts GAS and NEO only") } } -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -61,7 +61,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } diff --git a/audit/audit_contract.go b/audit/audit_contract.go index d405195..1f73609 100644 --- a/audit/audit_contract.go +++ b/audit/audit_contract.go @@ -27,7 +27,7 @@ type ( const maxKeySize = 24 // 24 + 32 (container ID length) + 8 (epoch length) = 64 func (a auditHeader) ID() []byte { - var buf interface{} = a.epoch + var buf any = a.epoch hashedKey := crypto.Sha256(a.from) shortedKey := hashedKey[:maxKeySize] @@ -39,11 +39,11 @@ const ( netmapContractKey = "netmapScriptHash" ) -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -63,7 +63,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -125,7 +125,7 @@ func List() [][]byte { // the specified epoch. func ListByEpoch(epoch int) [][]byte { ctx := storage.GetReadOnlyContext() - var buf interface{} = epoch + var buf any = epoch it := storage.Find(ctx, buf.([]byte), storage.KeysOnly) return list(it) @@ -136,7 +136,7 @@ func ListByEpoch(epoch int) [][]byte { func ListByCID(epoch int, cid []byte) [][]byte { ctx := storage.GetReadOnlyContext() - var buf interface{} = epoch + var buf any = epoch prefix := append(buf.([]byte), cid...) it := storage.Find(ctx, prefix, storage.KeysOnly) @@ -188,7 +188,7 @@ func Version() int { // readNext reads the length from the first byte, and then reads data (max 127 bytes). func readNext(input []byte) ([]byte, int) { - var buf interface{} = input[0] + var buf any = input[0] ln := buf.(int) return input[1 : 1+ln], 1 + ln @@ -199,7 +199,7 @@ func newAuditHeader(input []byte) auditHeader { offset := int(input[1]) offset = 2 + offset + 1 // version prefix + version len + epoch prefix - var buf interface{} = input[offset : offset+8] // [ 8 integer bytes ] + var buf any = input[offset : offset+8] // [ 8 integer bytes ] epoch := buf.(int) offset = offset + 8 diff --git a/balance/balance_contract.go b/balance/balance_contract.go index 455c7c6..803c819 100644 --- a/balance/balance_contract.go +++ b/balance/balance_contract.go @@ -63,11 +63,11 @@ func init() { token = createToken() } -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -89,7 +89,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -128,7 +128,7 @@ func BalanceOf(account interop.Hash160) int { // // It produces Transfer and TransferX notifications. TransferX notification // will have empty details field. -func Transfer(from, to interop.Hash160, amount int, data interface{}) bool { +func Transfer(from, to interop.Hash160, amount int, data any) bool { ctx := storage.GetContext() return token.transfer(ctx, from, to, amount, false, nil) } @@ -368,7 +368,7 @@ func isUsableAddress(addr interop.Hash160) bool { return false } -func getAccount(ctx storage.Context, key interface{}) Account { +func getAccount(ctx storage.Context, key any) Account { data := storage.Get(ctx, key) if data != nil { acc := std.Deserialize(data.([]byte)).(account) @@ -382,7 +382,7 @@ func getAccount(ctx storage.Context, key interface{}) Account { return Account{} } -func setAccount(ctx storage.Context, key interface{}, acc Account) { +func setAccount(ctx storage.Context, key any, acc Account) { common.SetSerialized(ctx, key, account{ Balance: common.ToFixedWidth64(acc.Balance), Until: common.ToFixedWidth64(acc.Until), diff --git a/common/storage.go b/common/storage.go index afa4e7b..8a184f3 100644 --- a/common/storage.go +++ b/common/storage.go @@ -7,7 +7,7 @@ import ( ) // SetSerialized serializes data and puts it into contract storage. -func SetSerialized(ctx storage.Context, key interface{}, value interface{}) { +func SetSerialized(ctx storage.Context, key any, value interface{}) { data := std.Serialize(value) storage.Put(ctx, key, data) } diff --git a/common/transfer.go b/common/transfer.go index b3eebdc..14a0129 100644 --- a/common/transfer.go +++ b/common/transfer.go @@ -31,7 +31,7 @@ func LockTransferDetails(txDetails []byte) []byte { } func UnlockTransferDetails(epoch int) []byte { - var buf interface{} = epoch + var buf any = epoch return append(unlockPrefix, buf.([]byte)...) } diff --git a/common/version.go b/common/version.go index 09dd6c9..50c6910 100644 --- a/common/version.go +++ b/common/version.go @@ -38,9 +38,9 @@ func CheckVersion(from int) { } // AppendVersion appends current contract version to the list of deploy arguments. -func AppendVersion(data interface{}) []interface{} { +func AppendVersion(data any) []interface{} { if data == nil { - return []interface{}{Version} + return []any{Version} } - return append(data.([]interface{}), Version) + return append(data.([]any), Version) } diff --git a/container/container_contract.go b/container/container_contract.go index 2ee2bea..18e50f6 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -85,14 +85,14 @@ const ( 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{}) { +func OnNEP11Payment(a interop.Hash160, b int, c []byte, d any) { } -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) it := storage.Find(ctx, []byte{}, storage.None) @@ -160,7 +160,7 @@ func registerNiceNameTLD(addrNNS interop.Hash160, nnsRoot string) { // Update method updates contract source code and manifest. It can be invoked // by committee only. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -323,7 +323,7 @@ func Delete(containerID []byte, signature interop.Signature, publicKey interop.P // and inability to delete a container. We should also check if we own the record in case. nnsContractAddr := storage.Get(ctx, nnsContractKey).(interop.Hash160) res := contract.Call(nnsContractAddr, "getRecords", contract.ReadStates|contract.AllowCall, domain, 16 /* TXT */) - if res != nil && std.Base58Encode(containerID) == string(res.([]interface{})[0].(string)) { + if res != nil && std.Base58Encode(containerID) == string(res.([]any)[0].(string)) { contract.Call(nnsContractAddr, "deleteRecords", contract.All, domain, 16 /* TXT */) } } @@ -540,7 +540,7 @@ func GetContainerSize(id []byte) containerSizes { func ListContainerSizes(epoch int) [][]byte { ctx := storage.GetReadOnlyContext() - var buf interface{} = epoch + var buf any = epoch key := []byte(estimateKeyPrefix) key = append(key, buf.([]byte)...) @@ -572,7 +572,7 @@ func ListContainerSizes(epoch int) [][]byte { func IterateContainerSizes(epoch int) iterator.Iterator { ctx := storage.GetReadOnlyContext() - var buf interface{} = epoch + var buf any = epoch key := []byte(estimateKeyPrefix) key = append(key, buf.([]byte)...) @@ -690,7 +690,7 @@ func ownerFromBinaryContainer(container []byte) []byte { } func estimationKey(epoch int, cid []byte, key interop.PublicKey) []byte { - var buf interface{} = epoch + var buf any = epoch hash := crypto.Ripemd160(key) @@ -768,7 +768,7 @@ func cleanupContainers(ctx storage.Context, epoch int) { // V2 format nbytes := k[len(estimateKeyPrefix) : len(k)-containerIDSize-estimatePostfixSize] - var n interface{} = nbytes + var n any = nbytes if epoch-n.(int) > TotalCleanupDelta { storage.Delete(ctx, k) diff --git a/frostfs/frostfs_contract.go b/frostfs/frostfs_contract.go index 765366a..5786a54 100644 --- a/frostfs/frostfs_contract.go +++ b/frostfs/frostfs_contract.go @@ -41,11 +41,11 @@ const ( var configPrefix = []byte("config") // _deploy sets up initial alphabet node keys. -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -93,7 +93,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by sidechain committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { blockHeight := ledger.CurrentIndex() alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1)) alphabetCommittee := common.Multiaddress(alphabetKeys, true) @@ -183,7 +183,7 @@ func InnerRingCandidateAdd(key interop.PublicKey) { // It takes no more than 9000.0 GAS. Native GAS has precision 8, and // FrostFS balance contract has precision 12. Values bigger than 9000.0 can // break JSON limits for integers when precision is converted. -func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { +func OnNEP17Payment(from interop.Hash160, amount int, data any) { rcv := data.(interop.Hash160) if common.BytesEqual(rcv, []byte(ignoreDepositNotification)) { return @@ -314,7 +314,7 @@ func Unbind(user []byte, keys []interop.PublicKey) { // Config returns configuration value of FrostFS configuration. If the key does // not exists, returns nil. -func Config(key []byte) interface{} { +func Config(key []byte) any { ctx := storage.GetReadOnlyContext() return getConfig(ctx, key) } @@ -369,7 +369,7 @@ func getAlphabetNodes(ctx storage.Context) []interop.PublicKey { } // getConfig returns the installed frostfs configuration value or nil if it is not set. -func getConfig(ctx storage.Context, key interface{}) interface{} { +func getConfig(ctx storage.Context, key any) interface{} { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) @@ -377,7 +377,7 @@ func getConfig(ctx storage.Context, key interface{}) interface{} { } // setConfig sets a frostfs configuration value in the contract storage. -func setConfig(ctx storage.Context, key, val interface{}) { +func setConfig(ctx storage.Context, key, val any) { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) diff --git a/frostfsid/frostfsid_contract.go b/frostfsid/frostfsid_contract.go index f3c1d3e..d736863 100644 --- a/frostfsid/frostfsid_contract.go +++ b/frostfsid/frostfsid_contract.go @@ -25,11 +25,11 @@ const ( ownerKeysPrefix = 'o' ) -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -51,7 +51,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -143,7 +143,7 @@ func Version() int { return common.Version } -func getUserInfo(ctx storage.Context, key interface{}) UserInfo { +func getUserInfo(ctx storage.Context, key any) UserInfo { it := storage.Find(ctx, key, storage.KeysOnly|storage.RemovePrefix) pubs := [][]byte{} for iterator.Next(it) { diff --git a/netmap/netmap_contract.go b/netmap/netmap_contract.go index 2a46a6e..1af6974 100644 --- a/netmap/netmap_contract.go +++ b/netmap/netmap_contract.go @@ -66,7 +66,7 @@ var ( ) // _deploy function sets up initial list of inner ring public keys. -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { ctx := storage.GetContext() args := data.(struct { @@ -117,7 +117,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -426,7 +426,7 @@ func SnapshotByEpoch(epoch int) []Node { // Config returns configuration value of FrostFS configuration. If key does // not exists, returns nil. -func Config(key []byte) interface{} { +func Config(key []byte) any { ctx := storage.GetReadOnlyContext() return getConfig(ctx, key) } @@ -538,14 +538,14 @@ func getSnapshot(ctx storage.Context, key string) []Node { return []Node{} } -func getConfig(ctx storage.Context, key interface{}) interface{} { +func getConfig(ctx storage.Context, key any) interface{} { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) return storage.Get(ctx, storageKey) } -func setConfig(ctx storage.Context, key, val interface{}) { +func setConfig(ctx storage.Context, key, val any) { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 2b4b898..d187584 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -76,7 +76,7 @@ type RecordState struct { } // Update updates NameService contract. -func Update(nef []byte, manifest string, data interface{}) { +func Update(nef []byte, manifest string, data any) { checkCommittee() // Calculating keys and serializing requires calling // std and crypto contracts. This can be helpful on update @@ -87,9 +87,9 @@ func Update(nef []byte, manifest string, data interface{}) { } // _deploy initializes defaults (total supply and registration price) on contract deploy. -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -128,10 +128,10 @@ func OwnerOf(tokenID []byte) interop.Hash160 { } // Properties returns a domain name and an expiration date of the specified domain. -func Properties(tokenID []byte) map[string]interface{} { +func Properties(tokenID []byte) map[string]any { ctx := storage.GetReadOnlyContext() ns := getNameState(ctx, tokenID) - return map[string]interface{}{ + return map[string]any{ "name": ns.Name, "expiration": ns.Expiration, } @@ -166,7 +166,7 @@ func TokensOf(owner interop.Hash160) iterator.Iterator { } // Transfer transfers the domain with the specified name to a new owner. -func Transfer(to interop.Hash160, tokenID []byte, data interface{}) bool { +func Transfer(to interop.Hash160, tokenID []byte, data any) bool { if !isValid(to) { panic(`invalid receiver`) } @@ -478,7 +478,7 @@ func updateBalance(ctx storage.Context, tokenId []byte, acc interop.Hash160, dif // postTransfer sends Transfer notification to the network and calls onNEP11Payment // method. -func postTransfer(from, to interop.Hash160, tokenID []byte, data interface{}) { +func postTransfer(from, to interop.Hash160, tokenID []byte, data any) { runtime.Notify("Transfer", from, to, 1, tokenID) if management.GetContract(to) != nil { contract.Call(to, "onNEP11Payment", contract.All, from, 1, tokenID, data) diff --git a/policy/policy_contract.go b/policy/policy_contract.go index b7e7b21..c3fc80e 100644 --- a/policy/policy_contract.go +++ b/policy/policy_contract.go @@ -17,7 +17,7 @@ const ( ) // _deploy function sets up initial list of inner ring public keys. -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { } func storageKey(prefix Kind, entityName, name string) []byte { diff --git a/processing/processing_contract.go b/processing/processing_contract.go index d6a5afa..ff0c1b7 100644 --- a/processing/processing_contract.go +++ b/processing/processing_contract.go @@ -19,16 +19,16 @@ const ( ) // OnNEP17Payment is a callback for NEP-17 compatible native GAS contract. -func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { +func OnNEP17Payment(from interop.Hash160, amount int, data any) { caller := runtime.GetCallingScriptHash() if !common.BytesEqual(caller, []byte(gas.Hash)) { common.AbortWithMessage("processing contract accepts GAS only") } } -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -50,7 +50,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by the sidechain committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { blockHeight := ledger.CurrentIndex() alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1)) alphabetCommittee := common.Multiaddress(alphabetKeys, true) diff --git a/proxy/proxy_contract.go b/proxy/proxy_contract.go index 8556aff..7157062 100644 --- a/proxy/proxy_contract.go +++ b/proxy/proxy_contract.go @@ -10,16 +10,16 @@ import ( ) // OnNEP17Payment is a callback for NEP-17 compatible native GAS contract. -func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { +func OnNEP17Payment(from interop.Hash160, amount int, data any) { caller := runtime.GetCallingScriptHash() if !common.BytesEqual(caller, []byte(gas.Hash)) { common.AbortWithMessage("proxy contract accepts GAS only") } } -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -29,7 +29,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } diff --git a/reputation/reputation_contract.go b/reputation/reputation_contract.go index 3899e0b..66e4b5d 100644 --- a/reputation/reputation_contract.go +++ b/reputation/reputation_contract.go @@ -14,9 +14,9 @@ const ( reputationCountPrefix = 'c' ) -func _deploy(data interface{}, isUpdate bool) { +func _deploy(data any, isUpdate bool) { if isUpdate { - args := data.([]interface{}) + args := data.([]any) common.CheckVersion(args[len(args)-1].(int)) return } @@ -26,7 +26,7 @@ func _deploy(data interface{}, isUpdate bool) { // Update method updates contract source code and manifest. It can be invoked // only by committee. -func Update(script []byte, manifest []byte, data interface{}) { +func Update(script []byte, manifest []byte, data any) { if !common.HasUpdateAccess() { panic("only committee can update contract") } @@ -113,7 +113,7 @@ func Version() int { } func storageID(epoch int, peerID []byte) []byte { - var buf interface{} = epoch + var buf any = epoch return append(buf.([]byte), peerID...) } diff --git a/tests/alphabet_test.go b/tests/alphabet_test.go index 5a4ff12..b11881c 100644 --- a/tests/alphabet_test.go +++ b/tests/alphabet_test.go @@ -21,7 +21,7 @@ const alphabetPath = "../alphabet" func deployAlphabetContract(t *testing.T, e *neotest.Executor, addrNetmap, addrProxy util.Uint160, name string, index, total int64) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml")) - args := make([]interface{}, 5) + args := make([]any, 5) args[0] = addrNetmap args[1] = addrProxy args[2] = name @@ -87,8 +87,8 @@ func TestVote(t *testing.T) { require.True(t, ok) cNewAlphabet := c.WithSigners(newAlphabet) - cNewAlphabet.InvokeFail(t, common.ErrAlphabetWitnessFailed, method, int64(0), []interface{}{newAlphabetPub}) - c.InvokeFail(t, "invalid epoch", method, int64(1), []interface{}{newAlphabetPub}) + cNewAlphabet.InvokeFail(t, common.ErrAlphabetWitnessFailed, method, int64(0), []any{newAlphabetPub}) + c.InvokeFail(t, "invalid epoch", method, int64(1), []any{newAlphabetPub}) setAlphabetRole(t, e, newAlphabetPub) transferNeoToContract(t, c) @@ -108,7 +108,7 @@ func TestVote(t *testing.T) { newInvoker := neoInvoker.WithSigners(newAlphabet) newInvoker.Invoke(t, stackitem.NewBool(true), "registerCandidate", newAlphabetPub) - c.Invoke(t, stackitem.Null{}, method, int64(0), []interface{}{newAlphabetPub}) + c.Invoke(t, stackitem.Null{}, method, int64(0), []any{newAlphabetPub}) // wait one block util // a new committee is accepted @@ -138,7 +138,7 @@ func setAlphabetRole(t *testing.T, e *neotest.Executor, new []byte) { designInvoker := e.CommitteeInvoker(designSH) // set committee as NeoFSAlphabet - designInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int64(noderoles.NeoFSAlphabet), []interface{}{new}) + designInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int64(noderoles.NeoFSAlphabet), []any{new}) } func getAlphabetAcc(t *testing.T, e *neotest.Executor) *wallet.Account { diff --git a/tests/balance_test.go b/tests/balance_test.go index 9ebe169..22d319b 100644 --- a/tests/balance_test.go +++ b/tests/balance_test.go @@ -14,7 +14,7 @@ const balancePath = "../balance" func deployBalanceContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml")) - args := make([]interface{}, 3) + args := make([]any, 3) args[0] = addrNetmap args[1] = addrContainer diff --git a/tests/container_test.go b/tests/container_test.go index 25b99e1..035910e 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -29,7 +29,7 @@ const ( ) func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 { - args := make([]interface{}, 5) + args := make([]any, 5) args[0] = addrNetmap args[1] = addrBalance args[2] = util.Uint160{} // not needed for now @@ -171,7 +171,7 @@ func TestContainerPut(t *testing.T) { acc := c.NewAccount(t) cnt := dummyContainer(acc) - putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token} + putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token} c.InvokeFail(t, "insufficient balance to create container", "put", putArgs...) balanceMint(t, cBal, acc, containerFee*1, []byte{}) @@ -187,7 +187,7 @@ func TestContainerPut(t *testing.T) { balanceMint(t, cBal, acc, containerFee*1, []byte{}) - putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token, "mycnt", ""} + putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "mycnt", ""} t.Run("no fee for alias", func(t *testing.T) { c.InvokeFail(t, "insufficient balance to create container", "putNamed", putArgs...) }) @@ -222,7 +222,7 @@ func TestContainerPut(t *testing.T) { balanceMint(t, cBal, acc, (containerFee+containerAliasFee)*1, []byte{}) - putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token, "domain", "cdn"} + putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "domain", "cdn"} c2 := c.WithSigners(c.Committee, acc) c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...) @@ -243,7 +243,7 @@ func TestContainerPut(t *testing.T) { acc := c.NewAccount(t) balanceMint(t, cBal, acc, totalPrice*totalContainers, []byte{}) cnt := dummyContainer(acc) - putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token, "precreated", ""} + putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "precreated", ""} c.Invoke(t, stackitem.Null{}, "putNamed", putArgs...) txs := make([]*transaction.Transaction, 0, containerPerBlock) @@ -313,7 +313,7 @@ func TestContainerDelete(t *testing.T) { t.Run("gas costs are the same for different epochs", func(t *testing.T) { _, cnt2 := addContainer(t, c, cBal) - args := []interface{}{cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token} + args := []any{cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token} tx := c.PrepareInvoke(t, "delete", args...) for _, e := range []int{126, 127, 128, 129, 65536} { @@ -404,7 +404,7 @@ func TestContainerSetEACL(t *testing.T) { }) e := dummyEACL(cnt.id) - setArgs := []interface{}{e.value, e.sig, e.pub, e.token} + setArgs := []any{e.value, e.sig, e.pub, e.token} cAcc := c.WithSigners(acc) cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "setEACL", setArgs...) diff --git a/tests/frostfs_test.go b/tests/frostfs_test.go index 6690c2b..5e820e6 100644 --- a/tests/frostfs_test.go +++ b/tests/frostfs_test.go @@ -21,24 +21,24 @@ import ( const frostfsPath = "../frostfs" func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160, - pubs keys.PublicKeys, config ...interface{}, + pubs keys.PublicKeys, config ...any, ) util.Uint160 { - args := make([]interface{}, 3) + args := make([]any, 3) args[0] = addrProc - arr := make([]interface{}, len(pubs)) + arr := make([]any, len(pubs)) for i := range pubs { arr[i] = pubs[i].Bytes() } args[1] = arr - args[2] = append([]interface{}{}, config...) + args[2] = append([]any{}, config...) c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml")) e.DeployContract(t, c, args) return c.Hash } -func newFrostFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) { +func newFrostFSInvoker(t *testing.T, n int, config ...any) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) { e := newExecutor(t) accounts := make([]*wallet.Account, n) diff --git a/tests/frostfsid_test.go b/tests/frostfsid_test.go index 446746d..46ef33e 100644 --- a/tests/frostfsid_test.go +++ b/tests/frostfsid_test.go @@ -17,7 +17,7 @@ import ( const frostfsidPath = "../frostfsid" func deployFrostFSIDContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 { - args := make([]interface{}, 2) + args := make([]any, 2) args[0] = addrNetmap args[1] = addrContainer @@ -56,7 +56,7 @@ func TestFrostFSID_AddKey(t *testing.T) { acc := e.NewAccount(t) owner := signerToOwner(acc) e.Invoke(t, stackitem.Null{}, "addKey", owner, - []interface{}{pubs[0], pubs[1]}) + []any{pubs[0], pubs[1]}) sort.Slice(pubs[:2], func(i, j int) bool { return bytes.Compare(pubs[i], pubs[j]) == -1 @@ -68,8 +68,8 @@ func TestFrostFSID_AddKey(t *testing.T) { e.Invoke(t, stackitem.NewArray(arr), "key", owner) t.Run("multiple addKey per block", func(t *testing.T) { - tx1 := e.PrepareInvoke(t, "addKey", owner, []interface{}{pubs[2]}) - tx2 := e.PrepareInvoke(t, "addKey", owner, []interface{}{pubs[3], pubs[4]}) + tx1 := e.PrepareInvoke(t, "addKey", owner, []any{pubs[2]}) + tx2 := e.PrepareInvoke(t, "addKey", owner, []any{pubs[3], pubs[4]}) e.AddNewBlock(t, tx1, tx2) e.CheckHalt(t, tx1.Hash(), stackitem.Null{}) e.CheckHalt(t, tx2.Hash(), stackitem.Null{}) @@ -88,7 +88,7 @@ func TestFrostFSID_AddKey(t *testing.T) { }) e.Invoke(t, stackitem.Null{}, "removeKey", owner, - []interface{}{pubs[1], pubs[5]}) + []any{pubs[1], pubs[5]}) arr = []stackitem.Item{ stackitem.NewBuffer(pubs[0]), stackitem.NewBuffer(pubs[2]), @@ -98,8 +98,8 @@ func TestFrostFSID_AddKey(t *testing.T) { e.Invoke(t, stackitem.NewArray(arr), "key", owner) t.Run("multiple removeKey per block", func(t *testing.T) { - tx1 := e.PrepareInvoke(t, "removeKey", owner, []interface{}{pubs[2]}) - tx2 := e.PrepareInvoke(t, "removeKey", owner, []interface{}{pubs[0], pubs[4]}) + tx1 := e.PrepareInvoke(t, "removeKey", owner, []any{pubs[2]}) + tx2 := e.PrepareInvoke(t, "removeKey", owner, []any{pubs[0], pubs[4]}) e.AddNewBlock(t, tx1, tx2) e.CheckHalt(t, tx1.Hash(), stackitem.Null{}) e.CheckHalt(t, tx2.Hash(), stackitem.Null{}) diff --git a/tests/netmap_test.go b/tests/netmap_test.go index 067a42a..a2f7ae4 100644 --- a/tests/netmap_test.go +++ b/tests/netmap_test.go @@ -20,22 +20,22 @@ import ( const netmapPath = "../netmap" -func deployNetmapContract(t *testing.T, e *neotest.Executor, addrBalance, addrContainer util.Uint160, config ...interface{}) util.Uint160 { +func deployNetmapContract(t *testing.T, e *neotest.Executor, addrBalance, addrContainer util.Uint160, config ...any) util.Uint160 { _, pubs, ok := vm.ParseMultiSigContract(e.Committee.Script()) require.True(t, ok) - args := make([]interface{}, 4) + args := make([]any, 4) args[0] = addrBalance args[1] = addrContainer - args[2] = []interface{}{pubs[0]} - args[3] = append([]interface{}{}, config...) + args[2] = []any{pubs[0]} + args[3] = append([]any{}, config...) c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml")) e.DeployContract(t, c, args) return c.Hash } -func newNetmapInvoker(t *testing.T, config ...interface{}) *neotest.ContractInvoker { +func newNetmapInvoker(t *testing.T, config ...any) *neotest.ContractInvoker { e := newExecutor(t) ctrNNS := neotest.CompileFile(t, e.CommitteeHash, nnsPath, path.Join(nnsPath, "config.yml")) diff --git a/tests/nns_test.go b/tests/nns_test.go index b64d84d..77a610c 100644 --- a/tests/nns_test.go +++ b/tests/nns_test.go @@ -141,8 +141,8 @@ func TestTLDRecord(t *testing.T) { func TestNNSRegisterMulti(t *testing.T) { c := newNNSInvoker(t, true) - newArgs := func(domain string, account neotest.Signer) []interface{} { - return []interface{}{ + newArgs := func(domain string, account neotest.Signer) []any { + return []any{ domain, account.ScriptHash(), "doesnt@matter.com", int64(101), int64(102), int64(103), int64(104), } diff --git a/tests/processing_test.go b/tests/processing_test.go index ac6c4e9..84fb8cf 100644 --- a/tests/processing_test.go +++ b/tests/processing_test.go @@ -14,7 +14,7 @@ const processingPath = "../processing" func deployProcessingContract(t *testing.T, e *neotest.Executor, addrFrostFS util.Uint160) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, processingPath, path.Join(processingPath, "config.yml")) - args := make([]interface{}, 1) + args := make([]any, 1) args[0] = addrFrostFS e.DeployContract(t, c, args) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 67b363c..845fb16 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -12,7 +12,7 @@ import ( const proxyPath = "../proxy" func deployProxyContract(t *testing.T, e *neotest.Executor, addrNetmap util.Uint160) util.Uint160 { - args := make([]interface{}, 1) + args := make([]any, 1) args[0] = addrNetmap c := neotest.CompileFile(t, e.CommitteeHash, proxyPath, path.Join(proxyPath, "config.yml")) diff --git a/tests/reputation_test.go b/tests/reputation_test.go index b8349c3..844e74f 100644 --- a/tests/reputation_test.go +++ b/tests/reputation_test.go @@ -16,7 +16,7 @@ func deployReputationContract(t *testing.T, e *neotest.Executor) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, reputationPath, path.Join(reputationPath, "config.yml")) - e.DeployContract(t, c, []interface{}{}) + e.DeployContract(t, c, []any{}) return c.Hash }