Hi,
I got couple of issues that could be turned into features or they might be already implemented and I don’t know about it.
- my mapping calls
supportsInterface
on an address that looks like this.
let contract = ERC721.bind(addressHere);
let result = ethereum.call(
new ethereum.SmartContractCall(
contract._name, // '',
contract._address, // address,
'supportsInterface', // '',
'supportsInterface(bytes4):(bool)',
[ethereum.Value.fromFixedBytes(Bytes.fromHexString('0x80ac58cd') as Bytes)]
)
);
if(result != null &&
(result as Array<ethereum.Value>)[0].toBoolean() == true)) {
// do something
}
when supportsInterface is called from mapping, and the function isn’t mocked in test,
it fails with: couldn’t find mocked function. why ? can’t we have supportsInterface so even if mocked function
not exists, it doesn’t fail ? and more importantly, if supportsInterface is called on a non-erc721, would the realtime subgraph fail or is this happening only in test ? I don’t want to be mocking the supportsInterface
in test and I simply want it to return null.
- The second problem I found is one test depens on another. If I mock supportsInterface in test 1, it’s also mocked in test 2 even though I didn’t mock it in test 2.
it("1", () => {
// I create mocked function here
})
it("2", () => {
// problem, the mocked function is still in cache in test 2
// and this is really bad.
})
is there clearCache
function ? and if so, should I be calling it in afterEach
? still not ideal.
- I got 5 tests written. Each of them tests something about ERC721. I end up having the following in all 5 tests.
// check ERC721Contract entity
assert.fieldEquals('ERC721Contract', tokenId, 'id', tokenId);
assert.fieldEquals('ERC721Contract', tokenId, 'name', 'name');
assert.fieldEquals('ERC721Contract', tokenId, 'symbol', 'symbol');
assert.entityCount('ERC721Contract', 1);
// check ERC721Balance entity
assert.fieldEquals('ERC721Balance', balanceId, 'id', balanceId);
assert.fieldEquals('ERC721Balance', balanceId, 'token', tokenId);
assert.fieldEquals('ERC721Balance', balanceId, 'dao', daoId);
assert.fieldEquals('ERC721Balance', balanceId, 'tokenIds', '[4, 12]');
assert.fieldEquals('ERC721Balance', balanceId, 'lastUpdated', timestamp.toString());
assert.entityCount('ERC721Balance', 1);
The reason I wanted the feature of having let
variables in describe block is, then I’d be able to have the chance that each test just sets the variables (tokenId, balanceId, daoId, timestamp
), and the above assertions would go in afterEach
and wouldn’t be duplicated. Isn’t there really a solution for this ? If I create assertionFunction
that includes the above, It’s not ideal.
Thank you so much