Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relayed guard accounts semi integration tests #5038

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions integrationTests/multiShard/relayedTx/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/multiversx/mx-chain-go/integrationTests"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/testscommon/txDataBuilder"
)

// CreateGeneralSetupForRelayTxTest will create the general setup for relayed transactions
Expand Down Expand Up @@ -158,21 +157,13 @@ func createRelayedTxV2(
userTx *transaction.Transaction,
gasLimitForUserTx uint64,
) *transaction.Transaction {
dataBuilder := txDataBuilder.NewBuilder()
txData := dataBuilder.
Func(core.RelayedTransactionV2).
Bytes(userTx.RcvAddr).
Int64(int64(userTx.Nonce)).
Bytes(userTx.Data).
Bytes(userTx.Signature)

tx := &transaction.Transaction{
Nonce: relayer.Nonce,
Value: big.NewInt(0).Set(userTx.Value),
RcvAddr: userTx.SndAddr,
SndAddr: relayer.Address,
GasPrice: integrationTests.MinTxGasPrice,
Data: txData.ToBytes(),
Data: integrationTests.PrepareRelayedTxDataV2(userTx),
ChainID: userTx.ChainID,
Version: userTx.Version,
}
Expand Down
20 changes: 20 additions & 0 deletions integrationTests/testInitializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
testStorage "github.com/multiversx/mx-chain-go/testscommon/state"
"github.com/multiversx/mx-chain-go/testscommon/statusHandler"
statusHandlerMock "github.com/multiversx/mx-chain-go/testscommon/statusHandler"
"github.com/multiversx/mx-chain-go/testscommon/txDataBuilder"
"github.com/multiversx/mx-chain-go/trie"
"github.com/multiversx/mx-chain-go/trie/hashesHolder"
"github.com/multiversx/mx-chain-go/vm"
Expand Down Expand Up @@ -2539,3 +2540,22 @@ func SaveDelegationContractsList(nodes []*TestProcessorNode) {
_, _ = n.AccntState.Commit()
}
}

// PrepareRelayedTxDataV1 repares the data for a relayed transaction V1
func PrepareRelayedTxDataV1(innerTx *transaction.Transaction) []byte {
userTxBytes, _ := TestMarshalizer.Marshal(innerTx)
return []byte(core.RelayedTransaction + "@" + hex.EncodeToString(userTxBytes))
}

// PrepareRelayedTxDataV2 prepares the data for a relayed transaction V2
func PrepareRelayedTxDataV2(innerTx *transaction.Transaction) []byte {
dataBuilder := txDataBuilder.NewBuilder()
txData := dataBuilder.
Func(core.RelayedTransactionV2).
Bytes(innerTx.RcvAddr).
Int64(int64(innerTx.Nonce)).
Bytes(innerTx.Data).
Bytes(innerTx.Signature)

return txData.ToBytes()
}
2 changes: 0 additions & 2 deletions integrationTests/vm/txsFee/asyncCall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestAsyncCallShouldWork(t *testing.T) {
_, _ = vm.CreateAccount(testContext.Accounts, ownerAddr, 0, egldBalance)
_, _ = vm.CreateAccount(testContext.Accounts, senderAddr, 0, egldBalance)

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(50000)

Expand Down Expand Up @@ -93,7 +92,6 @@ func TestMinterContractWithAsyncCalls(t *testing.T) {
token := []byte("miiutoken")
roles := [][]byte{[]byte(core.ESDTRoleNFTCreate)}

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(500000)
pathToContract := "testdata/minter/minter.wasm"
Expand Down
7 changes: 0 additions & 7 deletions integrationTests/vm/txsFee/asyncESDT_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func TestAsyncESDTCallShouldWork(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

// deploy 2 contracts
gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(50000)

Expand Down Expand Up @@ -89,7 +88,6 @@ func TestAsyncESDTCallSecondScRefusesPayment(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

// deploy 2 contracts
gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(50000)

Expand Down Expand Up @@ -143,7 +141,6 @@ func TestAsyncESDTCallsOutOfGas(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

// deploy 2 contracts
gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(50000)

Expand Down Expand Up @@ -193,7 +190,6 @@ func TestAsyncMultiTransferOnCallback(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, ownerAddr, big.NewInt(1000000000), sftTokenID, sftNonce, sftBalance)
utils.CheckESDTNFTBalance(t, testContext, ownerAddr, sftTokenID, sftNonce, sftBalance)

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(1000000)
txGasLimit := uint64(1000000)
Expand Down Expand Up @@ -287,7 +283,6 @@ func TestAsyncMultiTransferOnCallAndOnCallback(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, ownerAddr, big.NewInt(1000000000), sftTokenID, sftNonce, sftBalance)
utils.CheckESDTNFTBalance(t, testContext, ownerAddr, sftTokenID, sftNonce, sftBalance)

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(1000000)
txGasLimit := uint64(1000000)
Expand Down Expand Up @@ -387,7 +382,6 @@ func TestSendNFTToContractWith0Function(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, ownerAddr, big.NewInt(1000000000), sftTokenID, sftNonce, sftBalance)
utils.CheckESDTNFTBalance(t, testContext, ownerAddr, sftTokenID, sftNonce, sftBalance)

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(1000000)
txGasLimit := uint64(1000000)
Expand Down Expand Up @@ -437,7 +431,6 @@ func TestSendNFTToContractWith0FunctionNonPayable(t *testing.T) {
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, ownerAddr, big.NewInt(1000000000), sftTokenID, sftNonce, sftBalance)
utils.CheckESDTNFTBalance(t, testContext, ownerAddr, sftTokenID, sftNonce, sftBalance)

gasPrice := uint64(10)
ownerAccount, _ := testContext.Accounts.LoadAccount(ownerAddr)
deployGasLimit := uint64(1000000)
txGasLimit := uint64(1000000)
Expand Down
3 changes: 0 additions & 3 deletions integrationTests/vm/txsFee/backwardsCompatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestMoveBalanceSelfShouldWorkAndConsumeTxFeeWhenAllFlagsAreDisabled(t *test
sndAddr := []byte("12345678901234567890123456789012")
senderNonce := uint64(0)
senderBalance := big.NewInt(10000)
gasPrice := uint64(10)
gasLimit := uint64(100)

_, _ = vm.CreateAccount(testContext.Accounts, sndAddr, 0, senderBalance)
Expand Down Expand Up @@ -72,7 +71,6 @@ func TestMoveBalanceAllFlagsDisabledLessBalanceThanGasLimitMulGasPrice(t *testin
sndAddr := []byte("12345678901234567890123456789012")
senderNonce := uint64(0)
senderBalance := big.NewInt(10000)
gasPrice := uint64(10)
gasLimit := uint64(10000)

_, _ = vm.CreateAccount(testContext.Accounts, sndAddr, 0, senderBalance)
Expand All @@ -97,7 +95,6 @@ func TestMoveBalanceSelfShouldWorkAndConsumeTxFeeWhenSomeFlagsAreDisabled(t *tes
sndAddr := []byte("12345678901234567890123456789012")
senderNonce := uint64(0)
senderBalance := big.NewInt(10000)
gasPrice := uint64(10)
gasLimit := uint64(100)

_, _ = vm.CreateAccount(testContext.Accounts, sndAddr, 0, senderBalance)
Expand Down
7 changes: 0 additions & 7 deletions integrationTests/vm/txsFee/builtInFunctions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func TestBuildInFunctionChangeOwnerCallShouldWork(t *testing.T) {
utils.CleanAccumulatedIntermediateTransactions(t, testContext)

newOwner := []byte("12345678901234567890123456789112")
gasPrice := uint64(10)
gasLimit := uint64(1000)

txData := []byte(core.BuiltInFunctionChangeOwnerAddress + "@" + hex.EncodeToString(newOwner))
Expand Down Expand Up @@ -72,7 +71,6 @@ func TestBuildInFunctionChangeOwnerCallWrongOwnerShouldConsumeGas(t *testing.T)

sndAddr := []byte("12345678901234567890123456789113")
newOwner := []byte("12345678901234567890123456789112")
gasPrice := uint64(10)
gasLimit := uint64(1000)

_, _ = vm.CreateAccount(testContext.Accounts, sndAddr, 0, big.NewInt(100000))
Expand Down Expand Up @@ -109,7 +107,6 @@ func TestBuildInFunctionChangeOwnerInvalidAddressShouldConsumeGas(t *testing.T)
testContext.TxFeeHandler.CreateBlockStarted(getZeroGasAndFees())

newOwner := []byte("invalidAddress")
gasPrice := uint64(10)
gasLimit := uint64(1000)

txData := []byte(core.BuiltInFunctionChangeOwnerAddress + "@" + hex.EncodeToString(newOwner))
Expand Down Expand Up @@ -143,7 +140,6 @@ func TestBuildInFunctionChangeOwnerCallInsufficientGasLimitShouldNotConsumeGas(t
testContext.TxFeeHandler.CreateBlockStarted(getZeroGasAndFees())

newOwner := []byte("12345678901234567890123456789112")
gasPrice := uint64(10)

_, _ = vm.CreateAccount(testContext.Accounts, owner, 1, big.NewInt(10970))

Expand Down Expand Up @@ -181,7 +177,6 @@ func TestBuildInFunctionChangeOwnerOutOfGasShouldConsumeGas(t *testing.T) {
testContext.TxFeeHandler.CreateBlockStarted(getZeroGasAndFees())

newOwner := []byte("12345678901234567890123456789112")
gasPrice := uint64(10)

txData := []byte(core.BuiltInFunctionChangeOwnerAddress + "@" + hex.EncodeToString(newOwner))
gasLimit := uint64(len(txData) + 1)
Expand Down Expand Up @@ -226,7 +221,6 @@ func TestBuildInFunctionSaveKeyValue_WrongDestination(t *testing.T) {

txData := []byte(core.BuiltInFunctionSaveKeyValue + "@01@02")
gasLimit := uint64(len(txData) + 1)
gasPrice := uint64(10)

tx := vm.CreateTransaction(0, big.NewInt(0), sndAddr, destAddr, gasPrice, gasLimit, txData)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -259,7 +253,6 @@ func TestBuildInFunctionSaveKeyValue_NotEnoughGasFor3rdSave(t *testing.T) {

txData := []byte(core.BuiltInFunctionSaveKeyValue + "@01000000@02000000@03000000@04000000@05000000@06000000")
gasLimit := uint64(len(txData) + 20)
gasPrice := uint64(10)

tx := vm.CreateTransaction(0, big.NewInt(0), sndAddr, sndAddr, gasPrice, gasLimit, txData)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down
1 change: 0 additions & 1 deletion integrationTests/vm/txsFee/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestDeployDNSContract_TestRegisterAndResolveAndSendTxWithSndAndRcvUserName(

sndAddr := []byte("12345678901234567890123456789112")
senderBalance := big.NewInt(10000000)
gasPrice := uint64(10)
gasLimit := uint64(200000)

rcvAddr := []byte("12345678901234567890123456789113")
Expand Down
3 changes: 0 additions & 3 deletions integrationTests/vm/txsFee/esdtLocalBurn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestESDTLocalBurnShouldWork(t *testing.T) {
roles := [][]byte{[]byte(core.ESDTRoleLocalMint), []byte(core.ESDTRoleLocalBurn)}
utils.CreateAccountWithESDTBalanceAndRoles(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance, roles)

gasPrice := uint64(10)
gasLimit := uint64(40)
tx := utils.CreateESDTLocalBurnTx(0, sndAddr, sndAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -57,7 +56,6 @@ func TestESDTLocalBurnMoreThanTotalBalanceShouldErr(t *testing.T) {
roles := [][]byte{[]byte(core.ESDTRoleLocalMint), []byte(core.ESDTRoleLocalBurn)}
utils.CreateAccountWithESDTBalanceAndRoles(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance, roles)

gasPrice := uint64(10)
gasLimit := uint64(60)
tx := utils.CreateESDTLocalBurnTx(0, sndAddr, sndAddr, token, big.NewInt(100000001), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -87,7 +85,6 @@ func TestESDTLocalBurnNotAllowedShouldErr(t *testing.T) {
token := []byte("miiutoken")
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

gasPrice := uint64(10)
gasLimit := uint64(40)
tx := utils.CreateESDTLocalBurnTx(0, sndAddr, sndAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down
2 changes: 0 additions & 2 deletions integrationTests/vm/txsFee/esdtLocalMint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestESDTLocalMintShouldWork(t *testing.T) {
roles := [][]byte{[]byte(core.ESDTRoleLocalMint), []byte(core.ESDTRoleLocalBurn)}
utils.CreateAccountWithESDTBalanceAndRoles(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance, roles)

gasPrice := uint64(10)
gasLimit := uint64(40)
tx := utils.CreateESDTLocalMintTx(0, sndAddr, sndAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -56,7 +55,6 @@ func TestESDTLocalMintNotAllowedShouldErr(t *testing.T) {
token := []byte("miiutoken")
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

gasPrice := uint64(10)
gasLimit := uint64(40)
tx := utils.CreateESDTLocalMintTx(0, sndAddr, sndAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down
3 changes: 0 additions & 3 deletions integrationTests/vm/txsFee/esdt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestESDTTransferShouldWork(t *testing.T) {
token := []byte("miiutoken")
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

gasPrice := uint64(10)
gasLimit := uint64(40)
tx := utils.CreateESDTTransferTx(0, sndAddr, rcvAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -67,7 +66,6 @@ func TestESDTTransferShouldWorkToMuchGasShouldConsumeAllGas(t *testing.T) {
token := []byte("miiutoken")
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

gasPrice := uint64(10)
gasLimit := uint64(1000)
tx := utils.CreateESDTTransferTx(0, sndAddr, rcvAddr, token, big.NewInt(100), gasPrice, gasLimit)
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
Expand Down Expand Up @@ -104,7 +102,6 @@ func TestESDTTransferInvalidESDTValueShouldConsumeGas(t *testing.T) {
token := []byte("miiutoken")
utils.CreateAccountWithESDTBalance(t, testContext.Accounts, sndAddr, egldBalance, token, 0, esdtBalance)

gasPrice := uint64(10)
gasLimit := uint64(1000)
tx := utils.CreateESDTTransferTx(0, sndAddr, rcvAddr, token, big.NewInt(100000000+1), gasPrice, gasLimit)

Expand Down
Loading