-
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.
chore(acceptance-price-feeds): make sure old vats are quiescent and v…
…aults receive quotes Refs: #9928 Refs: Agoric/BytePitchPartnerEng#25 fix: lint fixes Refs: Agoric/BytePitchPartnerEng#25
- Loading branch information
1 parent
9d1ad9e
commit d3393aa
Showing
5 changed files
with
296 additions
and
42 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
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
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
103 changes: 103 additions & 0 deletions
103
a3p-integration/proposals/z:acceptance/test-lib/priceFeed-lib.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,103 @@ | ||
import test from 'ava'; | ||
import '@endo/init'; | ||
import { ensureGCDeliveryOnly } from './priceFeed-lib.js'; | ||
|
||
const testConfig = { | ||
before: { | ||
'-scaledPriceAuthority-stATOM': { v58: 13, v74: 119 }, | ||
'-scaledPriceAuthority-ATOM': { v46: 77, v73: 178 }, | ||
'-stATOM-USD_price_feed': { v57: 40, v72: 192 }, | ||
'-ATOM-USD_price_feed': { v29: 100, v70: 247 }, | ||
}, | ||
after: { | ||
'-scaledPriceAuthority-stATOM': { v58: 15, v74: 119 }, | ||
'-scaledPriceAuthority-ATOM': { v46: 79, v73: 178 }, | ||
'-stATOM-USD_price_feed': { v57: 42, v72: 192 }, | ||
'-ATOM-USD_price_feed': { v29: 102, v70: 247 }, | ||
}, | ||
}; | ||
|
||
const makeFakeGetTranscriptItemsForVat = ( | ||
deliveryType, | ||
maximumAllowedDeliveries, | ||
) => { | ||
const fakeGetTranscriptItemsForVat = (_, number) => { | ||
const fakeTranscriptItems = []; | ||
for (let i = 0; i < number; i += 1) { | ||
const item = { d: [deliveryType] }; | ||
fakeTranscriptItems.push({ item: JSON.stringify(item) }); | ||
} | ||
return fakeTranscriptItems; | ||
}; | ||
|
||
const tooManyTranscriptItemsForVat = () => { | ||
const fakeTranscriptItems = []; | ||
for (let i = 0; i <= maximumAllowedDeliveries; i += 1) { | ||
const item = { d: [deliveryType] }; | ||
fakeTranscriptItems.push({ item: JSON.stringify(item) }); | ||
} | ||
return fakeTranscriptItems; | ||
}; | ||
|
||
return { fakeGetTranscriptItemsForVat, tooManyTranscriptItemsForVat }; | ||
}; | ||
|
||
test('should not throw', t => { | ||
const { fakeGetTranscriptItemsForVat } = | ||
makeFakeGetTranscriptItemsForVat('dropExports'); | ||
|
||
t.notThrows(() => | ||
ensureGCDeliveryOnly(testConfig, { | ||
getTranscriptItems: fakeGetTranscriptItemsForVat, | ||
}), | ||
); | ||
}); | ||
|
||
test('should throw for "notify"', t => { | ||
const { fakeGetTranscriptItemsForVat } = | ||
makeFakeGetTranscriptItemsForVat('notify'); | ||
|
||
t.throws( | ||
() => | ||
ensureGCDeliveryOnly(testConfig, { | ||
getTranscriptItems: fakeGetTranscriptItemsForVat, | ||
}), | ||
{ message: 'DeliveryType "notify" is not GC delivery' }, | ||
); | ||
}); | ||
|
||
test('should throw for "message"', t => { | ||
const { fakeGetTranscriptItemsForVat } = | ||
makeFakeGetTranscriptItemsForVat('message'); | ||
|
||
t.throws( | ||
() => | ||
ensureGCDeliveryOnly(testConfig, { | ||
getTranscriptItems: fakeGetTranscriptItemsForVat, | ||
}), | ||
{ message: 'DeliveryType "message" is not GC delivery' }, | ||
); | ||
}); | ||
|
||
test('should throw too many deliveries', t => { | ||
const { fakeGetTranscriptItemsForVat } = makeFakeGetTranscriptItemsForVat( | ||
'dropExports', | ||
5, | ||
); | ||
|
||
const config = { | ||
...testConfig, | ||
after: { | ||
...testConfig.after, | ||
'-scaledPriceAuthority-stATOM': { v58: 20, v74: 119 }, | ||
}, | ||
}; | ||
|
||
t.throws( | ||
() => | ||
ensureGCDeliveryOnly(config, { | ||
getTranscriptItems: fakeGetTranscriptItemsForVat, | ||
}), | ||
{ message: '7 deliveries is greater than maximum allowed: 5' }, | ||
); | ||
}); |
Oops, something went wrong.