-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: robustify allManagersDo (#9833)
closes: #9706 ## Description make `allManagersDo` robust to errors thrown by one vaultManager ### Security Considerations Prevent issues in one vaultManager from blocking progress in others. This would affect liquidation and locking oracle prices for upcoming liquidation auctions. ### Scaling Considerations Doesn't add work. ### Documentation Considerations Not user visible ### Testing Considerations added a tiny unit test. ### Upgrade Considerations added robustness shouldn't impact upgrade.
- Loading branch information
1 parent
af5e7ab
commit e1baf4e
Showing
2 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
packages/inter-protocol/test/vaultFactory/director-allMgrsDo.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Far } from '@endo/marshal'; | ||
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import { waitUntilQuiescent } from '@agoric/swingset-liveslots/test/waitUntilQuiescent.js'; | ||
import { makeAllManagersDo } from '../../src/vaultFactory/vaultDirector.js'; | ||
|
||
const makeFakeVM = (name, thrower) => { | ||
let okay = true; | ||
const fakeVM = Far('fakeVM', { | ||
doIt: () => { | ||
if (thrower) { | ||
okay = false; | ||
throw Error('whatever', name); | ||
} | ||
return name; | ||
}, | ||
okay: () => okay, | ||
}); | ||
return { self: fakeVM }; | ||
}; | ||
|
||
const makeFakeVMgrKits = () => { | ||
const kits = []; | ||
return { | ||
add: k => kits.push(k), | ||
get: i => kits[i], | ||
}; | ||
}; | ||
|
||
test(`AllManagersDo no throw`, async t => { | ||
const collMgr = [0, 1, 2]; | ||
const kits = makeFakeVMgrKits(); | ||
kits.add(makeFakeVM('A', false)); | ||
kits.add(makeFakeVM('B', false)); | ||
kits.add(makeFakeVM('C', false)); | ||
|
||
const allManagersDo = makeAllManagersDo(collMgr, kits); | ||
// @ts-expect-error It's a fake | ||
const result = allManagersDo(vm => vm.doIt()); | ||
t.is(result, undefined); | ||
t.true(kits.get(0).self.okay()); | ||
t.true(kits.get(1).self.okay()); | ||
t.true(kits.get(2).self.okay()); | ||
}); | ||
|
||
test(`AllManagersDo throw`, async t => { | ||
const collMgr = [0, 1, 2]; | ||
const kits = makeFakeVMgrKits(); | ||
kits.add(makeFakeVM('A', false)); | ||
kits.add(makeFakeVM('B', true)); | ||
kits.add(makeFakeVM('C', false)); | ||
|
||
const allManagersDo = makeAllManagersDo(collMgr, kits); | ||
// @ts-expect-error It's a fake | ||
const result = allManagersDo(vm => vm.doIt()); | ||
t.is(result, undefined); | ||
|
||
await waitUntilQuiescent(); | ||
|
||
t.true(kits.get(0).self.okay()); | ||
t.false(kits.get(1).self.okay()); | ||
t.true(kits.get(2).self.okay()); | ||
}); |