mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
735d44ba32
* check receipt status for failed txs from evm * make EvmSigner's Auth public * setup evm state initialization for e2e * add a dummy Greeter contract, deployed on start * move WaitForEvmTxReceipt to from account to util * add tests for interacting with the contract * add ContractAddrs map to Chain
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package e2e_test
|
|
|
|
import (
|
|
"time"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/tests/e2e/contracts/greeter"
|
|
"github.com/kava-labs/kava/tests/util"
|
|
)
|
|
|
|
func (suite *IntegrationTestSuite) TestEthCallToGreeterContract() {
|
|
// this test manipulates state of the Greeter contract which means other tests shouldn't use it.
|
|
|
|
// setup funded account to interact with contract
|
|
user := suite.Kava.NewFundedAccount("greeter-contract-user", sdk.NewCoins(ukava(10e6)))
|
|
|
|
greeterAddr := suite.Kava.ContractAddrs["greeter"]
|
|
contract, err := greeter.NewGreeter(greeterAddr, suite.Kava.EvmClient)
|
|
suite.NoError(err)
|
|
|
|
beforeGreeting, err := contract.Greet(nil)
|
|
suite.NoError(err)
|
|
|
|
updatedGreeting := "look at me, using the evm"
|
|
tx, err := contract.SetGreeting(user.EvmAuth, updatedGreeting)
|
|
suite.NoError(err)
|
|
|
|
_, err = util.WaitForEvmTxReceipt(suite.Kava.EvmClient, tx.Hash(), 10*time.Second)
|
|
suite.NoError(err)
|
|
|
|
afterGreeting, err := contract.Greet(nil)
|
|
suite.NoError(err)
|
|
|
|
suite.Equal("what's up!", beforeGreeting)
|
|
suite.Equal(updatedGreeting, afterGreeting)
|
|
}
|