From 5a3ec4dab431c3b1a0f001a7a20a859ce9e46f0d Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Wed, 14 Feb 2024 14:28:11 +0200 Subject: [PATCH] - fixed linter issues --- factory/api/export_test.go | 1 + .../vm/wasm/upgrades/upgrades_test.go | 21 ++++++++++++------- .../consensusGroupProviderBench_test.go | 4 ---- ...dexHashedNodesCoordinatorWithRater_test.go | 4 ++-- trie/node_extension.go | 4 ++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/factory/api/export_test.go b/factory/api/export_test.go index 13f42c575ac..5a7948c9acb 100644 --- a/factory/api/export_test.go +++ b/factory/api/export_test.go @@ -49,6 +49,7 @@ func CreateScQueryElement(args SCQueryElementArgs) (process.SCQueryService, erro }) } +// CreateBlockchainForScQuery - func CreateBlockchainForScQuery(selfShardID uint32) (data.ChainHandler, error) { return createBlockchainForScQuery(selfShardID) } diff --git a/integrationTests/vm/wasm/upgrades/upgrades_test.go b/integrationTests/vm/wasm/upgrades/upgrades_test.go index 866029191d5..514507b0c04 100644 --- a/integrationTests/vm/wasm/upgrades/upgrades_test.go +++ b/integrationTests/vm/wasm/upgrades/upgrades_test.go @@ -182,38 +182,41 @@ func TestUpgrades_HelloTrialAndError(t *testing.T) { upgradeTxData := fmt.Sprintf("upgradeContract@%s@0100", wasm.GetSCCode("../testdata/hello-v2/output/answer.wasm")) // Deploy the smart contract. Alice is the owner - network.SendTransaction( + _, err := network.SendTransaction( alice.Address, make([]byte, 32), big.NewInt(0), deployTxData, 1000, ) + require.Nil(t, err) scAddress, _ := network.ShardNode.BlockchainHook.NewAddress(alice.Address, 0, factory.WasmVirtualMachine) network.Continue(t, 1) require.Equal(t, []byte{24}, query(t, network.ShardNode, scAddress, "getUltimateAnswer")) // Upgrade as Bob - upgrade should fail, since Alice is the owner - network.SendTransaction( + _, err = network.SendTransaction( bob.Address, scAddress, big.NewInt(0), upgradeTxData, 1000, ) + require.Nil(t, err) network.Continue(t, 1) require.Equal(t, []byte{24}, query(t, network.ShardNode, scAddress, "getUltimateAnswer")) // Now upgrade as Alice, should work - network.SendTransaction( + _, err = network.SendTransaction( alice.Address, scAddress, big.NewInt(0), upgradeTxData, 1000, ) + require.Nil(t, err) network.Continue(t, 1) require.Equal(t, []byte{42}, query(t, network.ShardNode, scAddress, "getUltimateAnswer")) @@ -236,50 +239,54 @@ func TestUpgrades_CounterTrialAndError(t *testing.T) { upgradeTxData := fmt.Sprintf("upgradeContract@%s@0100", wasm.GetSCCode("../testdata/counter/output/counter.wasm")) // Deploy the smart contract. Alice is the owner - network.SendTransaction( + _, err := network.SendTransaction( alice.Address, make([]byte, 32), big.NewInt(0), deployTxData, 1000, ) + require.Nil(t, err) scAddress, _ := network.ShardNode.BlockchainHook.NewAddress(alice.Address, 0, factory.WasmVirtualMachine) network.Continue(t, 1) require.Equal(t, []byte{1}, query(t, network.ShardNode, scAddress, "get")) // Increment the counter (could be either Bob or Alice) - network.SendTransaction( + _, err = network.SendTransaction( alice.Address, scAddress, big.NewInt(0), "increment", 1000, ) + require.Nil(t, err) network.Continue(t, 1) require.Equal(t, []byte{2}, query(t, network.ShardNode, scAddress, "get")) // Upgrade as Bob - upgrade should fail, since Alice is the owner (counter.init() not executed, state not reset) - network.SendTransaction( + _, err = network.SendTransaction( bob.Address, scAddress, big.NewInt(0), upgradeTxData, 1000, ) + require.Nil(t, err) network.Continue(t, 1) require.Equal(t, []byte{2}, query(t, network.ShardNode, scAddress, "get")) // Now upgrade as Alice, should work (state is reset by counter.init()) - network.SendTransaction( + _, err = network.SendTransaction( alice.Address, scAddress, big.NewInt(0), upgradeTxData, 1000, ) + require.Nil(t, err) network.Continue(t, 1) require.Equal(t, []byte{1}, query(t, network.ShardNode, scAddress, "get")) diff --git a/sharding/nodesCoordinator/consensusGroupProviderBench_test.go b/sharding/nodesCoordinator/consensusGroupProviderBench_test.go index c24f6f9549f..49731812213 100644 --- a/sharding/nodesCoordinator/consensusGroupProviderBench_test.go +++ b/sharding/nodesCoordinator/consensusGroupProviderBench_test.go @@ -1,11 +1,9 @@ package nodesCoordinator import ( - "math/rand" "testing" ) -const randSeed = 75 const numValidators = 63 const numValidatorsInEligibleList = 400 @@ -20,7 +18,6 @@ func getRandomness() []byte { func BenchmarkReslicingBasedProvider_Get(b *testing.B) { numVals := numValidators - rand.Seed(randSeed) expElList := getExpandedEligibleList(numValidatorsInEligibleList) randomness := getRandomness() @@ -32,7 +29,6 @@ func BenchmarkReslicingBasedProvider_Get(b *testing.B) { func BenchmarkSelectionBasedProvider_Get(b *testing.B) { numVals := numValidators - rand.Seed(randSeed) expElList := getExpandedEligibleList(numValidatorsInEligibleList) randomness := getRandomness() diff --git a/sharding/nodesCoordinator/indexHashedNodesCoordinatorWithRater_test.go b/sharding/nodesCoordinator/indexHashedNodesCoordinatorWithRater_test.go index 5d276deaaed..d74c38e9b0b 100644 --- a/sharding/nodesCoordinator/indexHashedNodesCoordinatorWithRater_test.go +++ b/sharding/nodesCoordinator/indexHashedNodesCoordinatorWithRater_test.go @@ -774,8 +774,8 @@ func BenchmarkIndexHashedGroupSelectorWithRater_TestExpandList(b *testing.B) { } //a := []int{1, 2, 3, 4, 5, 6, 7, 8} - rand.Seed(time.Now().UnixNano()) - rand.Shuffle(len(array), func(i, j int) { array[i], array[j] = array[j], array[i] }) + rnd := rand.New(rand.NewSource(time.Now().UnixNano())) + rnd.Shuffle(len(array), func(i, j int) { array[i], array[j] = array[j], array[i] }) m2 := runtime.MemStats{} runtime.ReadMemStats(&m2) diff --git a/trie/node_extension.go b/trie/node_extension.go index 4e7b38a6a7d..ffbdab699ad 100644 --- a/trie/node_extension.go +++ b/trie/node_extension.go @@ -26,8 +26,8 @@ func shouldTestNode(n node, key []byte) bool { } func snapshotGetTestPoint(key []byte, faultyChance int) error { - rand.Seed(time.Now().UnixNano()) - checkVal := rand.Intn(math.MaxInt) + rnd := rand.New(rand.NewSource(time.Now().UnixNano())) + checkVal := rnd.Intn(math.MaxInt) if checkVal%faultyChance == 0 { log.Debug("deliberately not returning hash", "hash", key) return fmt.Errorf("snapshot get error")