Skip to content

Commit

Permalink
Merge pull request #646 from onflow/janez/split-tests
Browse files Browse the repository at this point in the history
Split out cadence arch and traces tests
  • Loading branch information
m-Peter authored Nov 4, 2024
2 parents 7be7b44 + cba0da9 commit 7ba15bc
Show file tree
Hide file tree
Showing 8 changed files with 663 additions and 104 deletions.
14 changes: 14 additions & 0 deletions tests/e2e_web3js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ func TestWeb3_E2E(t *testing.T) {
runWeb3Test(t, "build_evm_state_test")
})

t.Run("verify Cadence arch calls", func(t *testing.T) {
t.Skip("not implemented yet")
runWeb3Test(t, "verify_cadence_arch_calls_test")
})

t.Run("test transaction traces", func(t *testing.T) {
t.Skip("not yet added back")
runWeb3Test(t, "debug_traces_test")
})

t.Run("test setup sanity check", func(t *testing.T) {
runWeb3Test(t, "setup_test")
})
Expand Down Expand Up @@ -56,6 +66,10 @@ func TestWeb3_E2E(t *testing.T) {
runWeb3Test(t, "eth_deploy_contract_and_interact_test")
})

t.Run("test retrieval of contract storage slots", func(t *testing.T) {
runWeb3Test(t, "eth_get_storage_at_test")
})

t.Run("deploy multicall3 contract and call methods", func(t *testing.T) {
runWeb3Test(t, "eth_multicall3_contract_test")
})
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func servicesSetup(t *testing.T) (emulator.Emulator, func()) {
LogWriter: testLogWriter(),
StreamTimeout: time.Second * 30,
StreamLimit: 10,
RateLimit: 50,
RateLimit: 500,
WSEnabled: true,
MetricsPort: 8443,
FilterExpiry: time.Second * 5,
Expand All @@ -177,7 +177,7 @@ func servicesSetup(t *testing.T) (emulator.Emulator, func()) {
// and will report failure or success of the test.
func executeTest(t *testing.T, testFile string) {
command := fmt.Sprintf(
"./web3js/node_modules/.bin/mocha ./web3js/%s.js --timeout 120s",
"./web3js/node_modules/.bin/mocha ./web3js/%s.js --timeout 150s",
testFile,
)
parts := strings.Fields(command)
Expand Down
79 changes: 0 additions & 79 deletions tests/web3js/build_evm_state_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,85 +237,6 @@ it('should handle a large number of EVM interactions', async () => {
gasPrice: conf.minGasPrice,
})
assert.equal(res.receipt.status, conf.successStatus)

// submit a transaction that calls verifyArchCallToRandomSource(uint64 height)
let getRandomSourceData = deployed.contract.methods.verifyArchCallToRandomSource(120).encodeABI()
res = await helpers.signAndSend({
from: conf.eoa.address,
to: contractAddress,
data: getRandomSourceData,
value: '0',
gasPrice: conf.minGasPrice,
})
assert.equal(res.receipt.status, conf.successStatus)

// make a contract call for verifyArchCallToRandomSource(uint64 height)
res = await web3.eth.call({ to: contractAddress, data: getRandomSourceData }, latest)
assert.notEqual(
res,
'0x0000000000000000000000000000000000000000000000000000000000000000'
)
assert.lengthOf(res, 66)

// submit a transaction that calls verifyArchCallToRevertibleRandom()
let revertibleRandomData = deployed.contract.methods.verifyArchCallToRevertibleRandom().encodeABI()
res = await helpers.signAndSend({
from: conf.eoa.address,
to: contractAddress,
data: revertibleRandomData,
value: '0',
gasPrice: conf.minGasPrice,
})
assert.equal(res.receipt.status, conf.successStatus)

// make a contract call for verifyArchCallToRevertibleRandom()
res = await web3.eth.call({ to: contractAddress, data: revertibleRandomData }, latest)
assert.notEqual(
res,
'0x0000000000000000000000000000000000000000000000000000000000000000'
)
assert.lengthOf(res, 66)

// submit a transaction that calls verifyArchCallToFlowBlockHeight()
let flowBlockHeightData = deployed.contract.methods.verifyArchCallToFlowBlockHeight().encodeABI()
res = await helpers.signAndSend({
from: conf.eoa.address,
to: contractAddress,
data: flowBlockHeightData,
value: '0',
gasPrice: conf.minGasPrice,
})
assert.equal(res.receipt.status, conf.successStatus)

// make a contract call for verifyArchCallToFlowBlockHeight()
res = await web3.eth.call({ to: contractAddress, data: flowBlockHeightData }, latest)
assert.equal(
web3.eth.abi.decodeParameter('uint64', res),
latest,
)

// submit a transaction that calls verifyArchCallToVerifyCOAOwnershipProof(address,bytes32,bytes)
let tx = await web3.eth.getTransactionFromBlock(conf.startBlockHeight, 1)
let verifyCOAOwnershipProofData = deployed.contract.methods.verifyArchCallToVerifyCOAOwnershipProof(
tx.to,
'0x1bacdb569847f31ade07e83d6bb7cefba2b9290b35d5c2964663215e73519cff',
web3.utils.hexToBytes('f853c18088f8d6e0586b0a20c78365766df842b840b90448f4591df2639873be2914c5560149318b7e2fcf160f7bb8ed13cfd97be2f54e6889606f18e50b2c37308386f840e03a9fff915f57b2164cba27f0206a95')
).encodeABI()
res = await helpers.signAndSend({
from: conf.eoa.address,
to: contractAddress,
data: verifyCOAOwnershipProofData,
value: '0',
gasPrice: conf.minGasPrice,
})
assert.equal(res.receipt.status, conf.successStatus)

// make a contract call for verifyArchCallToVerifyCOAOwnershipProof(address,bytes32,bytes)
res = await web3.eth.call({ to: contractAddress, data: verifyCOAOwnershipProofData }, latest)
assert.equal(
web3.eth.abi.decodeParameter('bool', res),
false,
)
})

function randomItem(items) {
Expand Down
Loading

0 comments on commit 7ba15bc

Please sign in to comment.