-
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
Porting upgrade tests to Javascript #8145
Conversation
if (run === 1) { | ||
try { | ||
const params = ['ec', 'committee', '--send-from', account]; | ||
await executeCommand(agopsLocation, params, { |
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.
This seems to be doing almost the same thing as line 47. Why is the syntax so different?
Was there a missed opportunity to turn line 39 into the agops.ec()
form, or is this intended to demonstrate the two styles of call?
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.
Ah good callout. At one point, there was a reason why I had to do it this way (to pass in custom options to execa), but I moved away from that approach, so I can converge this to look like the call below
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.
Actually, on second thought, the reason I did this was to pass in the timeout
option to execa
} | ||
} else { | ||
try { | ||
await agops.ec('committee', '--send-from', account, '--voter', voter); |
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.
It seems like if we're going to add helpers for agops subcommands, we could turn them into actual javascript calls rather than requiring the user to mimic the CLI version. It seems like the flags could be omitted, so the call here could be agops.ec(account, voter);
. [I don't know whether 'committee' is a flag or not. If the user has to specify the committee name, for instance, then that could be an extra parameter, and the javascript function's signature would help the caller know what arguments to provide.
return agops.auctioneer( | ||
'proposeParamChange', | ||
'--charterAcceptOfferId', | ||
charterAcceptOfferId, | ||
'--start-frequency', | ||
startFequency, | ||
'--clock-step', | ||
clockStep, | ||
'--price-lock-period', | ||
priceLockPeriod, | ||
); | ||
}; |
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.
This doesn't seem like an improvement over the shell syntax. Can we convert to JS style call? Would more work in the agops commands make this easier to support?
FASTER_AUCTIONS_OFFER=$(mktemp -t agops.XXX)
agops auctioneer proposeParamChange --charterAcceptOfferId "$(agops ec find-continuing-id --for "charter member invitation" --from "$GOV1ADDR")" --start-frequency $START_FREQUENCY --clock-step $CLOCK_STEP --price-lock-period $PRICE_LOCK_PERIOD >|"$FASTER_AUCTIONS_OFFER"
agoric wallet print --file "$FASTER_AUCTIONS_OFFER"
agops perf satisfaction --from "$GOV1ADDR" --executeOffer "$FASTER_AUCTIONS_OFFER" --keyring-backend=test
before I get into detailed feedback... Getting all this working in ci is great work! |
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.
Love it!
I left some comments and requests. Happy to hop on a call to go over them.
@@ -0,0 +1,348 @@ | |||
/* eslint-disable @jessie.js/safe-await-separator */ |
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.
remark: we should eventually update our configs so this suppression isn't necessary
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.
Here's the blurb explaining why it was setup in the first case. Is this no longer relevant?
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.
It's necessary for contract code. It's not a risk for deployment upgrade test code.
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-10/actions.mjs
Outdated
Show resolved
Hide resolved
let voter = 0; | ||
for (const account of govAccounts) { | ||
const runs = [1, 2]; | ||
for (const run of runs) { |
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.
a little funny to have a loop where most of the lines are conditional on the index.
import: refactor to a sequence of calls.
suggestion: helper function for doing whatever is in common
const offerFunction = async () => { | ||
return agops.oracle('accept', '--offerId', oracle.id); | ||
}; |
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 function is returning a promise but it's not async.
const offerFunction = async () => { | |
return agops.oracle('accept', '--offerId', oracle.id); | |
}; | |
const offerFunction = () => agops.oracle('accept', '--offerId', oracle.id); |
await submitDeliverInbound('user1'); | ||
|
||
const oracles = []; | ||
const oraclesAddresses = [GOV1ADDR, GOV2ADDR]; |
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.
important: hoist
); | ||
|
||
const govParams = await agoric.follow('-lF', ':published.auction.governance'); | ||
t.is(govParams.current.ClockStep.value.relValue, CLOCK_STEP.toString()); |
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.
that relvalue
is a string makes me think the unmarshaler needs work.
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.
Maybe we should file an issue to get this into the backlog?
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.
pretty sure it's a byproduct of the open coded unmarshaller
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-10/legacy.sh
Show resolved
Hide resolved
import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR } from '../constants.mjs'; | ||
import { calculateWalletState } from './upgradeHelpers.mjs'; | ||
|
||
test.serial( |
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.
in post.test.js
the tests needn't be serial because they're not supposed to affect the chain
important: remove serial in test that don't depend on it
cwd: '/usr/src/agoric-sdk', | ||
})`yarn bin agops`; | ||
|
||
export const agops = { |
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.
remark: I worry we're creating more work for ourselves by going from JS to shell and shell back to JS. This test is of upgrade . We don't need to integrate with Commander.js. We might better off importing the modules from agoric-cli
directly. We'd get type checking that way!
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.
just flushing a pending comment that I didn't mean to make pending
I don't understand what github is doing here
@@ -0,0 +1,20 @@ | |||
{ | |||
"type": "module", |
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.
Since we've got type module here, we use .js
instead of .mjs
?
const deadline = toSec(Date.now()) + voteDurSec; | ||
|
||
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]); | ||
const fromSmallCapsEntries = txt => { |
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.
all the smallcaps manipulations in the JS thingy I wrote are to avoid using anything outside the node standard library. Since we've now crossed over into using package.json
and such, this should switch to using @endo/marshal
in the normal way.
await waitForBlock(); | ||
}; | ||
|
||
export const ensureNewAuctionParams = async ( |
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.
Isn't this more like implementNewAuctionParams
? The test that calls does the ensure
part, I think.
(all the other verbs I can think of are too overloaded: you "pass" a resolution. Maybe 'enact'?)
address, | ||
); | ||
|
||
return paramChangeOfferGeneration(charterAcceptOfferId, 30, 123000000); |
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.
Seems like the new value should be a parameter. That way the test 'Ensure debt ceiling raised' could verify that the passed value matches the proposal.
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.
This may be refactored entirely, as stated here
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's more work to do before closing out #8137 but this is definite progress that I think is worth landing.
We have an urgent need to write new tests and this will allow us to write them in JS. We can always improve the code quality and DX incrementally.
); | ||
|
||
const govParams = await agoric.follow('-lF', ':published.auction.governance'); | ||
t.is(govParams.current.ClockStep.value.relValue, CLOCK_STEP.toString()); |
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.
pretty sure it's a byproduct of the open coded unmarshaller
Porting upgrade tests to Javascript
Porting upgrade tests to Javascript
refs: #8137
Description
Refactoring our bash scripts to look and feel more like Javascript. To accomplish portions of the scripts shelling out, we've leveraged. We intend to port all the upgrade tests, but started this endeavor with
agoric-upgrade-10
To discuss a few of the changes:
pre_test.sh
,actions.sh
, andtest.sh
have been moved. respectfully, topre.test.js
,actions.test.js
, andpost.test.js
.yarn upgrade-test
within theupgrade-test-scripts
folderenv_setup.sh