-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix!: in SmartWallet, if invitation is invalid, don't process offer #9240
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ const mockBootstrapPowers = async ( | |
log, | ||
spaceNames = ['installation', 'instance', 'issuer', 'brand'], | ||
) => { | ||
/** @type {import('@agoric/vat-data').Baggage} */ | ||
const baggage = makeScalarMapStore('bootstrap'); | ||
Comment on lines
+36
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does anybody know why the type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It can take There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
adding a link to track motivations: |
||
const zone = makeDurableZone(baggage); | ||
const { produce, consume } = makePromiseSpace(); | ||
|
@@ -82,7 +83,9 @@ const makeTestContext = async t => { | |
const makeSpendableAsset = () => { | ||
const tok1 = makeIssuerKit('Tok1'); | ||
const { issuer, brand } = bootKit.powers; | ||
// @ts-expect-error new symbol | ||
issuer.produce.Token1.resolve(tok1.issuer); | ||
// @ts-expect-error new symbol | ||
brand.produce.Token1.resolve(tok1.brand); | ||
return tok1; | ||
}; | ||
|
@@ -114,6 +117,7 @@ const makeTestContext = async t => { | |
/** @type {import('../src/smartWallet.js').BrandDescriptorRegistry} */ | ||
const registry = await makeRegistry(); | ||
|
||
/** @type {import('@agoric/vat-data').Baggage} */ | ||
const swBaggage = makeScalarMapStore('smart-wallet'); | ||
|
||
const secretWalletFactoryKey = Far('Key', {}); | ||
|
@@ -151,6 +155,7 @@ test.serial('handle failure to create invitation', async t => { | |
const invitationIssuer = powers.issuer.consume.Invitation; | ||
const address = 'agoric1234'; | ||
|
||
// @ts-expect-error Test setup ensures that chainStorage resolution is not undefined. (see #8247) | ||
const walletsStorage = E(chainStorage).makeChildNode('wallet'); | ||
const walletStorageNode = await E(walletsStorage).makeChildNode(address); | ||
|
||
|
@@ -167,14 +172,14 @@ test.serial('handle failure to create invitation', async t => { | |
const amt = AmountMath.make(spendable.brand, 100n); | ||
const pmt = await E(spendable.mint).mintPayment(amt); | ||
await E(purse).deposit(pmt); | ||
shared.thePurse = purse; | ||
const slowWithdrawPurse = { | ||
...purse, | ||
withdraw: async a => { | ||
await delay(100); | ||
console.log('@@slow withdraw', a); | ||
return E(purse).withdraw(a); | ||
}, | ||
getCurrentAmount: () => purse.getCurrentAmount(), | ||
}; | ||
return slowWithdrawPurse; | ||
}, | ||
|
@@ -183,10 +188,13 @@ test.serial('handle failure to create invitation', async t => { | |
}, | ||
}); | ||
|
||
const theBank = makeBank(); | ||
shared.thePurse = await theBank.getPurse(spendable.brand); | ||
|
||
const smartWallet = await makeSmartWallet({ | ||
address, | ||
walletStorageNode, | ||
bank: makeBank(), | ||
bank: theBank, | ||
invitationPurse, | ||
}); | ||
shared.theWallet = smartWallet; | ||
|
@@ -216,7 +224,7 @@ test.serial('handle failure to create invitation', async t => { | |
await delay(200); | ||
}); | ||
|
||
test.serial.failing('funds should be back in the purse', async t => { | ||
test.serial('funds should be back in the purse', async t => { | ||
t.like(t.context.shared.thePurse.getCurrentAmount(), { value: 100n }); | ||
}); | ||
|
||
|
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.
Looks like we're reconsidering the design from...
Is there anybody we should check with? The record only shows you, me, and @turadg as party to that issue and its fix.
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.
If I was part of that discussion, I've forgotten it.
Thanks for the off-line discussion. I'm comfortable that given what we know now, this order is better.