-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat: Check that makeInstance() returns an actual invite #904
Conversation
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.
Feel free to let me know if the changes I suggested aren't desirable.
packages/zoe/src/zoe.js
Outdated
@@ -543,7 +543,12 @@ const makeZoe = (additionalEndowments = {}) => { | |||
// Once the contract is made, we add the publicAPI to the | |||
// contractRecord | |||
instanceTable.update(instanceHandle, { publicAPI }); | |||
return invite; | |||
return inviteIssuer.isLive(invite).then(success => { | |||
if (success) { |
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.
Can we use an assert here and reverse the return and the error check?
if (success) { | |
assert(success, details`invites must be issued by the inviteIssuer.`); | |
return invite; |
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.
done.
const issuerKeywordRecord = harden({ Contribution: moolaR.issuer }); | ||
|
||
// 1: Alice tries to create an instance, but the contract is badly written. | ||
zoe.makeInstance(installationHandle, issuerKeywordRecord).then( |
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 think we should use t.throws
here. Is there a reason not to?
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.
makeInstance
is async. I couldn't find a way to await
the result. It doesn't throw until the test is done.
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.
t.rejects() works.
8313504
to
79a52c4
Compare
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.
Let's remove the test.only and then it looks good to me!
79a52c4
to
8d509c1
Compare
Includes a test. closes #820
8eab627
to
ab54fb9
Compare
ab54fb9
to
5509692
Compare
Includes a test.
closes #820