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

[FVM] beyond EVM part 7 - adding more evm-based contract types for testing #4872

Merged
merged 18 commits into from
Nov 15, 2023
Merged
10 changes: 5 additions & 5 deletions fvm/evm/emulator/emulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestNativeTokenBridging(t *testing.T) {
})
})
})
t.Run("mint tokens withdraw", func(t *testing.T) {
t.Run("tokens withdraw", func(t *testing.T) {
amount := big.NewInt(1000)
RunWithNewEmulator(t, db, func(env *emulator.Emulator) {
RunWithNewReadOnlyBlockView(t, env, func(blk types.ReadOnlyBlockView) {
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestNativeTokenBridging(t *testing.T) {
func TestContractInteraction(t *testing.T) {
RunWithTestDB(t, func(db types.Database) {

testContract := testutils.GetTestContract(t)
testContract := testutils.GetStorageTestContract(t)

testAccount := types.NewAddressFromString("test")
amount := big.NewInt(0).Mul(big.NewInt(1337), big.NewInt(gethParams.Ether))
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestContractInteraction(t *testing.T) {
types.NewContractCall(
testAccount,
contractAddr,
testContract.MakeStoreCallData(t, num),
testContract.MakeCallData(t, "store", num),
1_000_000,
big.NewInt(0), // this should be zero because the contract doesn't have receiver
),
Expand All @@ -164,7 +164,7 @@ func TestContractInteraction(t *testing.T) {
types.NewContractCall(
testAccount,
contractAddr,
testContract.MakeRetrieveCallData(t),
testContract.MakeCallData(t, "retrieve"),
1_000_000,
big.NewInt(0), // this should be zero because the contract doesn't have receiver
),
Expand All @@ -183,7 +183,7 @@ func TestContractInteraction(t *testing.T) {
types.NewContractCall(
testAccount,
contractAddr,
testContract.MakeBlockNumberCallData(t),
testContract.MakeCallData(t, "blockNumber"),
1_000_000,
big.NewInt(0), // this should be zero because the contract doesn't have receiver
),
Expand Down
15 changes: 9 additions & 6 deletions fvm/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/fvm/evm/stdlib"
. "github.com/onflow/flow-go/fvm/evm/testutils"

"github.com/onflow/flow-go/fvm/evm/types"
"github.com/onflow/flow-go/fvm/storage/snapshot"
"github.com/onflow/flow-go/model/flow"
Expand All @@ -26,7 +25,8 @@ func TestEVMRun(t *testing.T) {
t.Run("testing EVM.run (happy case)", func(t *testing.T) {
RunWithTestBackend(t, func(backend types.Backend) {
RunWithTestFlowEVMRootAddress(t, backend, func(rootAddr flow.Address) {
RunWithDeployedContract(t, backend, rootAddr, func(testContract *TestContract) {
tc := GetStorageTestContract(t)
RunWithDeployedContract(t, tc, backend, rootAddr, func(testContract *TestContract) {
RunWithEOATestAccount(t, backend, rootAddr, func(testAccount *EOATestAccount) {
num := int64(12)
chain := flow.Emulator.Chain()
Expand All @@ -49,7 +49,7 @@ func TestEVMRun(t *testing.T) {

txBytes := testAccount.PrepareSignAndEncodeTx(t,
testContract.DeployedAt.ToCommon(),
testContract.MakeStoreCallData(t, big.NewInt(num)),
testContract.MakeCallData(t, "store", big.NewInt(num)),
big.NewInt(0),
gasLimit,
big.NewInt(0),
Expand Down Expand Up @@ -115,7 +115,8 @@ func TestEVMAddressDeposit(t *testing.T) {

RunWithTestBackend(t, func(backend types.Backend) {
RunWithTestFlowEVMRootAddress(t, backend, func(rootAddr flow.Address) {
RunWithDeployedContract(t, backend, rootAddr, func(testContract *TestContract) {
tc := GetStorageTestContract(t)
RunWithDeployedContract(t, tc, backend, rootAddr, func(testContract *TestContract) {
RunWithEOATestAccount(t, backend, rootAddr, func(testAccount *EOATestAccount) {
chain := flow.Emulator.Chain()
RunWithNewTestVM(t, chain, func(ctx fvm.Context, vm fvm.VM, snapshot snapshot.SnapshotTree) {
Expand Down Expand Up @@ -167,7 +168,8 @@ func TestBridgedAccountWithdraw(t *testing.T) {

RunWithTestBackend(t, func(backend types.Backend) {
RunWithTestFlowEVMRootAddress(t, backend, func(rootAddr flow.Address) {
RunWithDeployedContract(t, backend, rootAddr, func(testContract *TestContract) {
tc := GetStorageTestContract(t)
RunWithDeployedContract(t, tc, backend, rootAddr, func(testContract *TestContract) {
RunWithEOATestAccount(t, backend, rootAddr, func(testAccount *EOATestAccount) {
chain := flow.Emulator.Chain()
RunWithNewTestVM(t, chain, func(ctx fvm.Context, vm fvm.VM, snapshot snapshot.SnapshotTree) {
Expand Down Expand Up @@ -225,7 +227,8 @@ func TestBridgedAccountDeploy(t *testing.T) {

RunWithTestBackend(t, func(backend types.Backend) {
RunWithTestFlowEVMRootAddress(t, backend, func(rootAddr flow.Address) {
RunWithDeployedContract(t, backend, rootAddr, func(testContract *TestContract) {
tc := GetStorageTestContract(t)
RunWithDeployedContract(t, tc, backend, rootAddr, func(testContract *TestContract) {
RunWithEOATestAccount(t, backend, rootAddr, func(testAccount *EOATestAccount) {
chain := flow.Emulator.Chain()
RunWithNewTestVM(t, chain, func(ctx fvm.Context, vm fvm.VM, snapshot snapshot.SnapshotTree) {
Expand Down
6 changes: 3 additions & 3 deletions fvm/evm/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,21 +517,21 @@ func TestHandler_BridgedAccount(t *testing.T) {
vault := types.NewFlowTokenVault(orgBalance)
foa.Deposit(vault)

testContract := testutils.GetTestContract(t)
testContract := testutils.GetStorageTestContract(t)
addr := foa.Deploy(testContract.ByteCode, math.MaxUint64, types.Balance(0))
require.NotNil(t, addr)

num := big.NewInt(22)

_ = foa.Call(
addr,
testContract.MakeStoreCallData(t, num),
testContract.MakeCallData(t, "store", num),
math.MaxUint64,
types.Balance(0))

ret := foa.Call(
addr,
testContract.MakeRetrieveCallData(t),
testContract.MakeCallData(t, "retrieve"),
math.MaxUint64,
types.Balance(0))

Expand Down
Loading
Loading