Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
e2e fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Oct 30, 2023
1 parent a88d2ff commit de844fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
10 changes: 8 additions & 2 deletions e2e-polybft/e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1437,10 +1437,13 @@ func TestE2E_Bridge_Transfers_AccessLists(t *testing.T) {
checkStateSyncResultLogs(t, logs, totalTransfers)

// check receivers balances got increased by deposited amount
// because we premined validators
expectedBalance := new(big.Int).Add(command.DefaultPremineBalance, depositAmount)

for _, receiver := range receivers {
balance, err := childEthEndpoint.GetBalance(ethgo.Address(types.StringToAddress(receiver)), ethgo.Latest)
require.NoError(t, err)
require.Equal(t, depositAmount, balance)
require.Equal(t, expectedBalance, balance)
}

t.Log("Deposits were successfully processed")
Expand Down Expand Up @@ -1608,7 +1611,10 @@ func TestE2E_Bridge_Transfers_WithRootTrackerPollInterval(t *testing.T) {
// check validator balance got increased by deposited amount
balance, err := childEthEndpoint.GetBalance(ethgo.Address(senderAccount.Address()), ethgo.Latest)
require.NoError(t, err)
require.Equal(t, tokensToDeposit, balance)

// because we premined the validators
expectedBalance := new(big.Int).Add(command.DefaultPremineBalance, tokensToDeposit)
require.Equal(t, expectedBalance, balance)
}

func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) {
Expand Down
23 changes: 7 additions & 16 deletions e2e-polybft/e2e/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import (
var uint256ABIType = abi.MustNewType("tuple(uint256)")

func TestE2E_Consensus_Basic_WithNonValidators(t *testing.T) {
const epochSize = 4
const (
epochSize = 4
validatorsNum = 5
)

cluster := framework.NewTestCluster(t, 5,
cluster := framework.NewTestCluster(t, validatorsNum,
framework.WithEpochSize(epochSize),
framework.WithNonValidators(2),
framework.WithTestRewardToken(),
Expand All @@ -44,8 +47,8 @@ func TestE2E_Consensus_Basic_WithNonValidators(t *testing.T) {
relayer, err := txrelayer.NewTxRelayer(txrelayer.WithClient(cluster.Servers[0].JSONRPC()))
require.NoError(t, err)

// because we are using native token as reward wallet, and it has default premine balance
initialTotalSupply := new(big.Int).Set(command.DefaultPremineBalance)
// because we are pre-mining native tokens to validators
initialTotalSupply := new(big.Int).Mul(big.NewInt(validatorsNum), command.DefaultPremineBalance)

// check if initial total supply of native ERC20 token is the same as expected
totalSupply := queryNativeERC20Metadata(t, "totalSupply", uint256ABIType, relayer)
Expand Down Expand Up @@ -600,18 +603,6 @@ func TestE2E_Consensus_CustomRewardToken(t *testing.T) {

cluster.WaitForReady(t)

// initialize tx relayer
relayer, err := txrelayer.NewTxRelayer(txrelayer.WithClient(cluster.Servers[0].JSONRPC()))
require.NoError(t, err)

// because we are not using native token as reward wallet, and have no premine
// initial token supply should be 0
initialTotalSupply := big.NewInt(0)

// check if initial total supply of native ERC20 token is the same as expected
totalSupply := queryNativeERC20Metadata(t, "totalSupply", uint256ABIType, relayer)
require.True(t, initialTotalSupply.Cmp(totalSupply.(*big.Int)) == 0) //nolint:forcetypeassert

// wait for couple of epochs to accumulate some rewards
require.NoError(t, cluster.WaitForBlock(epochSize*3, 3*time.Minute))

Expand Down
4 changes: 2 additions & 2 deletions e2e-polybft/framework/test-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (t *TestBridge) deployStakeManager(genesisPath string) error {

func (t *TestBridge) mintNativeRootToken(validatorAddresses []types.Address, tokenConfig *polybft.TokenConfig,
polybftConfig polybft.PolyBFTConfig) error {
if tokenConfig.IsMintable || t.clusterConfig.BurnContract == nil {
if tokenConfig.IsMintable {
// if token is mintable, it is premined in genesis command,
// so we just return here
return nil
Expand Down Expand Up @@ -598,7 +598,7 @@ func (t *TestBridge) mintNativeRootToken(validatorAddresses []types.Address, tok

func (t *TestBridge) premineNativeRootToken(tokenConfig *polybft.TokenConfig,
polybftConfig polybft.PolyBFTConfig) error {
if tokenConfig.IsMintable || t.clusterConfig.BurnContract == nil {
if tokenConfig.IsMintable {
// if token is mintable, it is premined in genesis command,
// so we just return here
return nil
Expand Down

0 comments on commit de844fd

Please sign in to comment.