3

I use sol-coverage in a truffle project. Ganache is my development blockchain. I have a lot of tests which end up doing more than a few thousand JSON RPC calls.

Due to unbeknownst reasons, the eth_getTransactionReceipt command fails to return the receipt object after ~1,000 calls. Instead I get the transaction hash, which breaks sol-coverage, because the expected result is either "null" or an object (as per the official docs).

Here's the function from the @0x codebase where the issue occurs:

public async getTransactionReceiptIfExistsAsync(txHash: string): Promise<TransactionReceipt | undefined> {
    assert.isHexString('txHash', txHash);
    const transactionReceiptRpc = await this.sendRawPayloadAsync<TransactionReceiptRPC>({
        method: 'eth_getTransactionReceipt',
        params: [txHash],
    });
    // HACK Parity can return a pending transaction receipt. We check for a non null
    // block number before continuing with returning a fully realised receipt.
    // ref: https://github.com/paritytech/parity-ethereum/issues/1180
    if (transactionReceiptRpc !== null && transactionReceiptRpc.blockNumber !== null) {
        transactionReceiptRpc.status = Web3Wrapper._normalizeTxReceiptStatus(transactionReceiptRpc.status);
        const transactionReceipt = marshaller.unmarshalTransactionReceipt(transactionReceiptRpc);
        return transactionReceipt;
    } else {
        return undefined;
    }
}

And my environment:

  • ganache-cli 6.6.0
  • sol-coverage 3.0.10
  • truffle 5.0.34

It this a bug with ganache?

  • Please show the relevant code (Solidity and Javascript) - wild guess - you forgot an await. – goodvibration Sep 4 at 13:17
  • It's not my code, it's 0x's. I updated the answer. – Paul Berg Sep 4 at 13:21
  • This is not Javascript, while both Truffle and Solidity-Coverage are Javascript-based projects. What's the deal here? – goodvibration Sep 4 at 13:23
  • 1
    @goodvibration's you're confusing 0x's sol-coverage with sc-forks's solidity-coverage. sol-coverage is written in Typescript. – Paul Berg Sep 4 at 13:28
  • Oh, I don't know why truffle test doesn't break but MODE=coverage truffle test does. That's why I asked the question and I mentioned that it happens specifically when I measure test coverage. – Paul Berg Sep 4 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.