-
Notifications
You must be signed in to change notification settings - Fork 1
tests: run ganache with --blockTime 1 & adjust tests #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| .onConfirmation(onConfirmationSpy) | ||
| .onceConfirmedReceipt(3, onceConfirmedReceiptSpy) | ||
| .onceTxRevert(onceTxRevertSpy); | ||
| } catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a fail within the try block to ensure an exception was thrown. Same pattern should apply to the subsequent checks (instead of isUndefined).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you mean by fail within the block? .send should throw, that's what testing here. As for txHash isUndefined I'm not sure what you mean. Am I miss something? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern to properly check exceptions:
try {
doStuff();
assert.fail(); // we shouldn’t reach this line
} catch (e) {
// validate the error
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, you could also use fail for callbacks that shouldn’t be called. Maybe shorter/clearer than spy...
| assert.equal(onceConfirmedReceiptSpy.callCount, 0); | ||
| }); | ||
|
|
||
| /** This doesn't work with ganache --blockTime 1 : can't get error in any ways with web3 beta36 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But works on rinkeby?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't try this particular yet, good point.
test/Transaction.test.js
Outdated
| assert.deepEqual(error, errorCaught); | ||
| }); | ||
|
|
||
| assert.isUndefined(txHash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant instead of isUndefined:
try {
await tx.getTxHash();
assert.fail();
} catch (error) {
assert.deepEqual(error, errorCaught);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I suppose other styles are possible (see https://www.chaijs.com/plugins/chai-as-promised/)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used chai-as-promised even in this test. I can't recall why not in this particular case, maybe it was less convenient.
--blockTime 1(which is closer how real chains work) and adjust tests to behaviourTransactionSendErrorif.sendfails..getTxHash,getTxReceiptandgetConfirmedReceiptare also rejected with that error