Skip to content

sapphire-contracts: Fix flaky Delegate then begin Undelegate (with receipts) test #684

@matevz

Description

@matevz
SUMMARY

Subcall tests for Undelegate started failing

receipt = await tx.wait();

I suspect something changed in the sapphire-localnet image between Mar 4-12 2026. Most notably the change of oasis-core from 25.6 to the master branch oasisprotocol/oasis-web3-gateway@53f8eb1?

e.g. https://github.com/oasisprotocol/sapphire-paratime/actions/runs/23000912350/job/67218415241?pr=682

I can reproduce this locally using sapphire-localnet:

Image
ISSUE TYPE
  • Bug Report
STEPS TO REPRODUCE

Spin up sapphire-localnet, then:

cd contracts
npx hardhat test --network sapphire-localnet --grep "Delegate then begin Undelegate"
ACTUAL RESULTS
  1) Subcall
       Delegate then begin Undelegate (with receipts):
     Error: transaction execution reverted (action="sendTransaction", data=null, reason=null, invocation=null, revert=null, transaction={ "data": "", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "to": "0x36b58F5C1969B7b6591D752ea6F5486D069010AB" }, receipt={ "_type": "TransactionReceipt", "blobGasPrice": null, "blobGasUsed": null, "blockHash": "0x8b9b3cb318579984de0e66e3f039d9b393478cc36afaa0eaaba443bc09646482", "blockNumber": 440, "contractAddress": null, "cumulativeGasUsed": "41064", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "gasPrice": "100000000000", "gasUsed": "41064", "hash": "0x40caf9bd0eca0e0f4ecb8eeb200de2a303d86888fbf28b5fbc256e31697e71a2", "index": 0, "logs": [  ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": 0, "to": "0x36b58F5C1969B7b6591D752ea6F5486D069010AB" }, code=CALL_EXCEPTION, version=6.13.5)
      at makeError (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/ethers@6.13.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at assert (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/ethers@6.13.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/src.ts/utils/errors.ts:715:25)
      at checkReceipt (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/ethers@6.13.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/src.ts/providers/provider.ts:1585:19)
      at ContractTransactionResponse.wait (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/ethers@6.13.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/src.ts/providers/provider.ts:1602:24)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async ContractTransactionResponse.wait (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/ethers@6.13.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/src.ts/contract/wrappers.ts:136:25)
      at async Context.<anonymous> (test/subcall.ts:313:15)

The workaround is to wait a few seconds before calling await contract.testTakeReceipt(3, result.receipt);

EXPECTED RESULTS

Test passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contractsPull requests that update sapphire-contractstestsRelating to tests

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions