From c312b1b65d33a16a2c9765cc904306a7a10f1282 Mon Sep 17 00:00:00 2001 From: salaheldinsoliman Date: Fri, 5 Jul 2024 12:21:14 +0200 Subject: [PATCH] restructure wiki-howtos --- packages/vm/core/evm/evmtest/evm_test.go | 89 ------------------------ 1 file changed, 89 deletions(-) diff --git a/packages/vm/core/evm/evmtest/evm_test.go b/packages/vm/core/evm/evmtest/evm_test.go index 6b31dd5df4..437e7f2cef 100644 --- a/packages/vm/core/evm/evmtest/evm_test.go +++ b/packages/vm/core/evm/evmtest/evm_test.go @@ -23,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/rpc" "github.com/samber/lo" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" iotago "github.com/iotaledger/iota.go/v3" @@ -2730,91 +2729,3 @@ func TestDisableMagicWrap(t *testing.T) { envWithMagicWrap := InitEVM(t, true) require.NotNil(t, envWithMagicWrap.getCode(envWithMagicWrap.ERC20BaseTokens(nil).address)) } - -func TestBaseBalance(t *testing.T) { - env := InitEVMWithSolo(t, solo.New(t), true) - privateKey, deployer := env.Chain.NewEthereumAccountWithL2Funds() - - instance := env.DeployContract(privateKey, evmtest.GetBalanceContractABI, evmtest.GetBalanceContractBytecode) - - balance, _ := env.Chain.EVM().Balance(deployer, nil) - decimals := env.Chain.EVM().BaseToken().Decimals - var value uint64 - instance.CallFnExpectEvent(nil, "GotBaseBalance", &value, "getBalanceBaseTokens") - realBalance := util.BaseTokensDecimalsToEthereumDecimals(value, decimals) - assert.Equal(t, balance, realBalance) -} - -func TestNativeBalance(t *testing.T) { - env := InitEVMWithSolo(t, solo.New(t), true) - privateKey, deployer := env.Chain.NewEthereumAccountWithL2Funds() - - instance := env.DeployContract(privateKey, evmtest.GetBalanceContractABI, evmtest.GetBalanceContractBytecode) - - // create a new native token on L1 - foundry, tokenID, err := env.Chain.NewNativeTokenParams(100000000000000).CreateFoundry() - require.NoError(t, err) - // the token id in bytes, used to call the contract - nativeTokenIDBytes := isc.NativeTokenIDToBytes(tokenID) - - // mint some native tokens to the chain originator - err = env.Chain.MintTokens(foundry, 10000000, env.Chain.OriginatorPrivateKey) - require.NoError(t, err) - - // get the agentId of the contract deployer - senderAgentID := isc.NewEthereumAddressAgentID(env.Chain.ChainID, deployer) - - // send some native tokens to the contract deployer - // and check if the balance returned by the contract is correct - err = env.Chain.SendFromL2ToL2AccountNativeTokens(tokenID, senderAgentID, 100000, env.Chain.OriginatorPrivateKey) - require.NoError(t, err) - - nativeBalance := new(big.Int) - instance.CallFnExpectEvent(nil, "GotNativeTokenBalance", &nativeBalance, "getBalanceNativeTokens", nativeTokenIDBytes) - assert.Equal(t, int64(100000), nativeBalance.Int64()) -} - -func TestNFTBalance(t *testing.T) { - env := InitEVMWithSolo(t, solo.New(t), true) - privateKey, deployer := env.Chain.NewEthereumAccountWithL2Funds() - - instance := env.DeployContract(privateKey, evmtest.GetBalanceContractABI, evmtest.GetBalanceContractBytecode) - - // get the agentId of the contract deployer - senderAgentID := isc.NewEthereumAddressAgentID(env.Chain.ChainID, deployer) - - // mint an NFToken to the contract deployer - // and check if the balance returned by the contract is correct - mockMetaData := []byte("sesa") - nfti, info, err := env.Chain.Env.MintNFTL1(env.Chain.OriginatorPrivateKey, env.Chain.OriginatorAddress, mockMetaData) - require.NoError(t, err) - env.Chain.MustDepositNFT(nfti, env.Chain.OriginatorAgentID, env.Chain.OriginatorPrivateKey) - - transfer := isc.NewEmptyAssets() - transfer.AddNFTs(info.NFTID) - - // send the NFT to the contract deployer - err = env.Chain.SendFromL2ToL2Account(transfer, senderAgentID, env.Chain.OriginatorPrivateKey) - require.NoError(t, err) - - // get the NFT balance of the contract deployer - nftBalance := new(big.Int) - instance.CallFnExpectEvent(nil, "GotNFTIDs", &nftBalance, "getBalanceNFTs") - assert.Equal(t, int64(1), nftBalance.Int64()) -} - -func TestAgentID(t *testing.T) { - env := InitEVMWithSolo(t, solo.New(t), true) - privateKey, deployer := env.Chain.NewEthereumAccountWithL2Funds() - - instance := env.DeployContract(privateKey, evmtest.GetBalanceContractABI, evmtest.GetBalanceContractBytecode) - - // get the agentId of the contract deployer - senderAgentID := isc.NewEthereumAddressAgentID(env.Chain.ChainID, deployer) - - // get the agnetId of the contract deployer - // and compare it with the agentId returned by the contract - var agentID []byte - instance.CallFnExpectEvent(nil, "GotAgentID", &agentID, "getAgentID") - assert.Equal(t, senderAgentID.Bytes(), agentID) -}