Skip to content

Commit

Permalink
Fix property tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Nov 6, 2023
1 parent 9ace673 commit c69e40d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
10 changes: 5 additions & 5 deletions e2e-polybft/e2e/acls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestE2E_AllowList_ContractDeployment(t *testing.T) {
otherAddr := types.Address{0x1}

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithPremine(adminAddr, targetAddr),
framework.WithContractDeployerAllowListAdmin(adminAddr),
framework.WithContractDeployerAllowListEnabled(otherAddr),
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestE2E_BlockList_ContractDeployment(t *testing.T) {
otherAddr := types.Address{0x1}

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithPremine(adminAddr, targetAddr),
framework.WithContractDeployerBlockListAdmin(adminAddr),
framework.WithContractDeployerBlockListEnabled(otherAddr),
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestE2E_AllowList_Transactions(t *testing.T) {
otherAddr := types.Address(other.Address())

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithPremine(adminAddr, targetAddr, otherAddr),
framework.WithTransactionsAllowListAdmin(adminAddr),
framework.WithTransactionsAllowListEnabled(otherAddr),
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestE2E_BlockList_Transactions(t *testing.T) {
otherAddr := types.Address(other.Address())

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithPremine(adminAddr, targetAddr, otherAddr),
framework.WithTransactionsBlockListAdmin(adminAddr),
framework.WithTransactionsBlockListEnabled(otherAddr),
Expand Down Expand Up @@ -392,7 +392,7 @@ func TestE2E_AddressLists_Bridge(t *testing.T) {
otherAddr := types.Address(other.Address())

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithPremine(adminAddr, targetAddr, otherAddr),
framework.WithBridgeAllowListAdmin(adminAddr),
framework.WithBridgeAllowListEnabled(otherAddr),
Expand Down
8 changes: 4 additions & 4 deletions e2e-polybft/e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func TestE2E_Bridge_ERC721Transfer(t *testing.T) {

cluster := framework.NewTestCluster(t, 5,
framework.WithEpochSize(epochSize),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, minter.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithPremine(types.Address(minter.Address())),
framework.WithPremine(receiversAddrs...))
defer cluster.Stop()
Expand Down Expand Up @@ -657,7 +657,7 @@ func TestE2E_Bridge_ERC1155Transfer(t *testing.T) {
cluster := framework.NewTestCluster(t, 5,
framework.WithNumBlockConfirmations(0),
framework.WithEpochSize(epochSize),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, minter.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithPremine(types.Address(minter.Address())),
framework.WithPremine(receiversAddrs...))
defer cluster.Stop()
Expand Down Expand Up @@ -857,7 +857,7 @@ func TestE2E_Bridge_ChildChainMintableTokensTransfer(t *testing.T) {
cluster := framework.NewTestCluster(t, 5,
framework.WithNumBlockConfirmations(0),
framework.WithEpochSize(epochSize),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, adminAddr)),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, adminAddr)),
framework.WithBridgeBlockListAdmin(adminAddr),
framework.WithPremine(append(depositors, adminAddr)...)) //nolint:makezero
defer cluster.Stop()
Expand Down Expand Up @@ -1215,7 +1215,7 @@ func TestE2E_Bridge_ChangeVotingPower(t *testing.T) {
cluster := framework.NewTestCluster(t, 5,
framework.WithEpochSize(epochSize),
framework.WithEpochReward(1000000),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, minter.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithPremine(types.Address(minter.Address())),
)
defer cluster.Stop()
Expand Down
6 changes: 3 additions & 3 deletions e2e-polybft/e2e/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestE2E_Consensus_RegisterValidator(t *testing.T) {
cluster := framework.NewTestCluster(t, validatorSetSize,
framework.WithEpochSize(epochSize),
framework.WithEpochReward(int(ethgo.Ether(1).Uint64())),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, minter.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithSecretsCallback(func(addresses []types.Address, config *framework.TestClusterConfig) {
config.Premine = append(config.Premine, fmt.Sprintf("%s:%s", minter.Address(), initMinterBalance))
for _, a := range addresses {
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestE2E_Consensus_Validator_Unstake(t *testing.T) {
cluster := framework.NewTestCluster(t, 5,
framework.WithEpochReward(int(ethgo.Ether(1).Uint64())),
framework.WithEpochSize(5),
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, minter.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithSecretsCallback(func(addresses []types.Address, config *framework.TestClusterConfig) {
config.Premine = append(config.Premine, fmt.Sprintf("%s:%d", minter.Address(), minterBalance))
for _, a := range addresses {
Expand Down Expand Up @@ -646,7 +646,7 @@ func TestE2E_Consensus_EIP1559Check(t *testing.T) {

// first account should have some matics premined
cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, sender1.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, sender1.Address())),
framework.WithPremine(types.Address(sender1.Address()), types.Address(sender2.Address())),
framework.WithBurnContract(&polybft.BurnContractInfo{BlockNumber: 0, Address: types.ZeroAddress}),
)
Expand Down
2 changes: 0 additions & 2 deletions e2e-polybft/e2e/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
"github.com/0xPolygon/polygon-edge/types"
)

const nativeTokenMintableTestCfg = "Mintable Edge Coin:MEC:18:true:%s"

// getCheckpointManagerValidators queries rootchain validator set on CheckpointManager contract
func getCheckpointManagerValidators(relayer txrelayer.TxRelayer, checkpointManagerAddr ethgo.Address) ([]*polybft.ValidatorInfo, error) {
validatorsCountRaw, err := ABICall(relayer, contractsapi.CheckpointManager,
Expand Down
2 changes: 1 addition & 1 deletion e2e-polybft/e2e/jsonrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestE2E_JsonRPC(t *testing.T) {
require.NoError(t, err)

cluster := framework.NewTestCluster(t, 4,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, acct.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, acct.Address())),
framework.WithPremine(types.Address(acct.Address())),
)
defer cluster.Stop()
Expand Down
8 changes: 4 additions & 4 deletions e2e-polybft/e2e/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestE2E_TxPool_Transfer(t *testing.T) {
require.NoError(t, err)

cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, sender.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, sender.Address())),
framework.WithPremine(types.Address(sender.Address())),
framework.WithBurnContract(&polybft.BurnContractInfo{BlockNumber: 0, Address: types.ZeroAddress}))
defer cluster.Stop()
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestE2E_TxPool_Transfer_Linear(t *testing.T) {

// first account should have some matics premined
cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, premine.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, premine.Address())),
framework.WithPremine(types.Address(premine.Address())),
framework.WithBurnContract(&polybft.BurnContractInfo{BlockNumber: 0, Address: types.ZeroAddress}),
)
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestE2E_TxPool_TransactionWithHeaderInstructions(t *testing.T) {
require.NoError(t, err)

cluster := framework.NewTestCluster(t, 4,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, sidechainKey.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, sidechainKey.Address())),
framework.WithPremine(types.Address(sidechainKey.Address())),
)
defer cluster.Stop()
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestE2E_TxPool_BroadcastTransactions(t *testing.T) {

// First account should have some matics premined
cluster := framework.NewTestCluster(t, 5,
framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, sender.Address())),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, sender.Address())),
framework.WithPremine(types.Address(sender.Address())),
framework.WithBurnContract(&polybft.BurnContractInfo{BlockNumber: 0, Address: types.ZeroAddress}),
)
Expand Down
3 changes: 3 additions & 0 deletions e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const (

// prefix for non validators directory
nonValidatorPrefix = "test-non-validator-"

// NativeTokenMintableTestCfg is the test native token config for Supernets originated native tokens
NativeTokenMintableTestCfg = "Mintable Edge Coin:MEC:18:true:%s" //nolint:gosec
)

type NodeType int
Expand Down
9 changes: 9 additions & 0 deletions e2e-polybft/property/property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/umbracle/ethgo/wallet"
"pgregory.net/rapid"

"github.com/0xPolygon/polygon-edge/e2e-polybft/framework"
Expand All @@ -21,6 +22,9 @@ func TestProperty_DifferentVotingPower(t *testing.T) {
maxStake = 20
)

minter, err := wallet.GenerateKey()
require.NoError(t, err)

rapid.Check(t, func(tt *rapid.T) {
var (
numNodes = rapid.Uint64Range(5, 8).Draw(tt, "number of cluster nodes")
Expand All @@ -40,6 +44,7 @@ func TestProperty_DifferentVotingPower(t *testing.T) {
cluster := framework.NewPropertyTestCluster(t, int(numNodes),
framework.WithEpochSize(epochSize),
framework.WithBlockTime(blockTime),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithSecretsCallback(func(adresses []types.Address, config *framework.TestClusterConfig) {
for i := range adresses {
config.StakeAmounts = append(config.StakeAmounts, stakes[i])
Expand All @@ -60,6 +65,9 @@ func TestProperty_DropValidators(t *testing.T) {
blockTime = time.Second * 4
)

minter, err := wallet.GenerateKey()
require.NoError(t, err)

rapid.Check(t, func(tt *rapid.T) {
var (
numNodes = rapid.Uint64Range(5, 8).Draw(tt, "number of cluster nodes")
Expand All @@ -69,6 +77,7 @@ func TestProperty_DropValidators(t *testing.T) {
cluster := framework.NewPropertyTestCluster(t, int(numNodes),
framework.WithEpochSize(epochSize),
framework.WithBlockTime(blockTime),
framework.WithNativeTokenConfig(fmt.Sprintf(framework.NativeTokenMintableTestCfg, minter.Address())),
framework.WithSecretsCallback(func(adresses []types.Address, config *framework.TestClusterConfig) {
for range adresses {
config.StakeAmounts = append(config.StakeAmounts, big.NewInt(20))
Expand Down

0 comments on commit c69e40d

Please sign in to comment.