Skip to content

Commit

Permalink
- fixed linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau committed Feb 14, 2024
1 parent 54869fa commit 5a3ec4d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions factory/api/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func CreateScQueryElement(args SCQueryElementArgs) (process.SCQueryService, erro
})
}

// CreateBlockchainForScQuery -
func CreateBlockchainForScQuery(selfShardID uint32) (data.ChainHandler, error) {
return createBlockchainForScQuery(selfShardID)
}
21 changes: 14 additions & 7 deletions integrationTests/vm/wasm/upgrades/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down
4 changes: 0 additions & 4 deletions sharding/nodesCoordinator/consensusGroupProviderBench_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package nodesCoordinator

import (
"math/rand"
"testing"
)

const randSeed = 75
const numValidators = 63
const numValidatorsInEligibleList = 400

Expand All @@ -20,7 +18,6 @@ func getRandomness() []byte {

func BenchmarkReslicingBasedProvider_Get(b *testing.B) {
numVals := numValidators
rand.Seed(randSeed)
expElList := getExpandedEligibleList(numValidatorsInEligibleList)
randomness := getRandomness()

Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions trie/node_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5a3ec4d

Please sign in to comment.