-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test (unsuccessfull) of kread contract after repair
- Loading branch information
1 parent
1b296cc
commit adc4f87
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
a3p-integration/proposals/a:upgrade-14/create-kread-item-test.sh
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,18 @@ | ||
source /usr/src/upgrade-test-scripts/env_setup.sh | ||
|
||
#test_val "$(agd q vstorage data published.wallet.$GOV1ADDR -o json | jq -r .value)" "" "ensure gov1 not provisioned" | ||
|
||
## nice try; can't use provisionSmartWallet to get IST | ||
#govamount="200000000ubld,250000000uist" | ||
|
||
govamount="200000000ubld" | ||
provisionSmartWallet $GOV1ADDR $govamount | ||
|
||
KREAD_ITEM_OFFER=$(mktemp -t kreadItem.XXX) | ||
|
||
echo "************************" about to generate kread proposal "************************" | ||
node ./generate-kread-item-request.mjs > $KREAD_ITEM_OFFER | ||
cat $KREAD_ITEM_OFFER | ||
echo "**********************" | ||
|
||
agops perf satisfaction --from $GOV1ADDR --executeOffer $KREAD_ITEM_OFFER --keyring-backend=test |
84 changes: 84 additions & 0 deletions
84
a3p-integration/proposals/a:upgrade-14/generate-kread-item-request.mjs
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,84 @@ | ||
/* global process */ | ||
import assert from 'assert'; | ||
import { execFile } from 'child_process'; | ||
|
||
const ISTunit = 1_000_000n; // aka displayInfo: { decimalPlaces: 6 } | ||
|
||
const [_node, _script] = process.argv; | ||
|
||
const toSec = ms => BigInt(Math.round(ms / 1000)); | ||
|
||
const id = `KREAd-test-${Date.now()}`; | ||
|
||
// poor-man's zx | ||
const $ = cmd => { | ||
console.error(cmd); | ||
const [file, ...args] = cmd.split(' '); | ||
|
||
return new Promise((resolve, reject) => { | ||
execFile(file, args, { encoding: 'utf8' }, (err, out) => { | ||
if (err) return reject(err); | ||
resolve(out); | ||
}); | ||
}); | ||
}; | ||
|
||
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]); | ||
const fromSmallCapsEntries = txt => { | ||
const { body, slots } = JSON.parse(txt); | ||
const theEntries = zip(JSON.parse(body.slice(1)), slots).map( | ||
([[name, ref], boardID]) => { | ||
const iface = ref.replace(/^\$\d+\./, ''); | ||
return [name, { iface, boardID }]; | ||
}, | ||
); | ||
return Object.fromEntries(theEntries); | ||
}; | ||
|
||
const brand = fromSmallCapsEntries( | ||
await $('agoric follow -lF :published.agoricNames.brand -o text'), | ||
); | ||
assert(brand.IST); | ||
assert(brand.KREAdCHARACTER); | ||
|
||
const slots = []; // XXX global mutable state | ||
|
||
const smallCaps = { | ||
Nat: n => `+${n}`, | ||
// XXX mutates obj | ||
ref: obj => { | ||
if (obj.ix) return obj.ix; | ||
const ix = slots.length; | ||
slots.push(obj.boardID); | ||
obj.ix = `$${ix}.Alleged: ${obj.iface}`; | ||
return obj.ix; | ||
}, | ||
}; | ||
|
||
const body = { | ||
method: 'executeOffer', | ||
offer: { | ||
id, | ||
invitationSpec: { | ||
source: 'agoricContract', | ||
instancePath: ['KREAd'], | ||
callPipe: [['makeMintCharacterInvite', []]], | ||
}, | ||
offerArgs: { name: 'ephemeral Ace' }, | ||
proposal: { | ||
give: { | ||
Price: { | ||
brand: smallCaps.ref(brand.IST), | ||
value: smallCaps.Nat(3n * ISTunit) } | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const bigIntReplacer = (_key, val) => | ||
typeof val === 'bigint' ? Number(val) : val; | ||
|
||
const capData = { body: `#${JSON.stringify(body, bigIntReplacer)}`, slots }; | ||
const action = JSON.stringify(capData); | ||
|
||
console.log(action); |
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 |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
source /usr/src/upgrade-test-scripts/env_setup.sh | ||
|
||
yarn ava | ||
|
||
./create-kread-item-test.sh |