-
Notifications
You must be signed in to change notification settings - Fork 7
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
contract test to act like UI client #20
Comments
If we resolve the vow, we see that the test fails.
change to resolve the vowdiff --git a/contract/package.json b/contract/package.json
index f176af3..79b9fc3 100644
--- a/contract/package.json
+++ b/contract/package.json
@@ -30,7 +30,6 @@
"@agoric/time": "dev",
"@agoric/vat-data": "dev",
"@agoric/xsnap": "dev",
- "@agoric/zone": "^0.2.2",
"@cosmjs/amino": "^0.32.3",
"@cosmjs/proto-signing": "^0.32.3",
"@endo/eslint-plugin": "^2.2.0",
diff --git a/contract/src/orca.flows.js b/contract/src/orca.flows.js
index e9cccf1..91426fb 100644
--- a/contract/src/orca.flows.js
+++ b/contract/src/orca.flows.js
@@ -21,7 +21,7 @@ const trace = makeTracer('OrchFlows');
* @param {ZCFSeat} seat
* @param {{ chainName: string }} offerArgs
*/
-export const makeAccount = async (orch, _ctx, seat, { chainName }) => {
+export const makeAccount = async (orch, _ctx, seat, offerArgs) => {
const { give } = seat.getProposal();
trace('version 0.1.36');
trace('give');
@@ -31,8 +31,9 @@ export const makeAccount = async (orch, _ctx, seat, { chainName }) => {
trace(orch);
trace('seat');
trace(seat);
- trace(chainName);
+ trace(offerArgs);
seat.exit();
+ const { chainName } = offerArgs;
const chain = await orch.getChain(chainName);
trace('chain object');
trace(chain);
diff --git a/contract/test/orca-contract.test.js b/contract/test/orca-contract.test.js
index 36d5706..eee1248 100644
--- a/contract/test/orca-contract.test.js
+++ b/contract/test/orca-contract.test.js
@@ -9,6 +9,8 @@ import { E, Far } from '@endo/far';
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
import { makeZoeKitForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { AmountMath, makeIssuerKit } from '@agoric/ertp';
+import { makeHeapZone } from '@agoric/zone';
+import { prepareSwingsetVowTools } from '@agoric/vow/vat.js';
import { startOrcaContract } from '../src/orca.proposal.js';
@@ -42,6 +44,9 @@ const makeTestContext = async t => {
const bundle = await bundleCache.load(contractPath, 'orca');
const tools = await makeMockTools(t, bundleCache);
+ const rootZone = makeHeapZone();
+ const vowTools = prepareSwingsetVowTools(rootZone.subZone('vows'));
+
const makeDummyStorageNode = (nodeName = 'rootNode') => {
return Far('DummyStorageNode', {
makeChildNode: async childName => {
@@ -210,6 +215,7 @@ const makeTestContext = async t => {
agoricNames,
storageNode: makeDummyStorageNode(),
marshaller: makeDummyMarshaller(),
+ vowTools,
...tools,
};
};
@@ -384,6 +390,7 @@ const orchestrationAccountScenario = test.macro({
agoricNames,
storageNode,
marshaller,
+ vowTools: vt,
} = t.context;
t.log('installing the contract...');
const installation = E(zoe).install(bundle);
@@ -434,7 +441,7 @@ const orchestrationAccountScenario = test.macro({
t.log('initial user seat:', initialUserSeat);
t.log('getting offer result...');
- const offerResult = await E(initialUserSeat).getOfferResult();
+ const offerResult = await vt.when(E(initialUserSeat).getOfferResult());
t.log('offer result:', offerResult);
t.truthy(offerResult, 'Offer result should exist');
diff --git a/yarn.lock b/yarn.lock
index 56e39bb..ae19072 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2090,7 +2090,7 @@ __metadata:
languageName: node
linkType: hard
-"@agoric/zone@npm:0.2.3-dev-7f12e80.0+7f12e80":
+"@agoric/zone@npm:0.2.3-dev-7f12e80.0+7f12e80, @agoric/zone@npm:dev":
version: 0.2.3-dev-7f12e80.0
resolution: "@agoric/zone@npm:0.2.3-dev-7f12e80.0"
dependencies:
@@ -10877,7 +10877,7 @@ __metadata:
"@agoric/vow": "npm:dev"
"@agoric/xsnap": "npm:dev"
"@agoric/zoe": "npm:dev"
- "@agoric/zone": "npm:^0.2.2"
+ "@agoric/zone": "npm:dev"
"@cosmjs/amino": "npm:^0.32.3"
"@cosmjs/proto-signing": "npm:^0.32.3"
"@endo/bundle-source": "npm:^3.3.0" |
interesting, good catch. This test wasn't updated when we added the offer arg for |
In the current tests, vstorage queries are mocked in such a way that they're completely disconnected from the operation of the contract: dapp-orchestration-basics/contract/test/orca-contract.test.js Lines 217 to 230 in 486f4eb
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's important to have a test to nail down the interface between the contract and clients such as the UI.
I'm pretty sure the contract requires offerArgs of the form
{ chainName }
and the UI supplies that when it makes offers.The test code, on the other hand, provides offerArgs of the form
{ id: offerId }
:dapp-orchestration-basics/contract/test/orca-contract.test.js
Lines 428 to 433 in 2379c1a
I was surprised that this test code works.
Diagnosis: the offer handler in the contract is an async flow, so it returns a vow. The client code in the test doesn't resolve the vow:
dapp-orchestration-basics/contract/test/orca-contract.test.js
Line 437 in 2379c1a
So the offer handler doesn't actually run.
cc @Jovonni @turadg
The text was updated successfully, but these errors were encountered: