Skip to content

Commit

Permalink
refactor: sync submitEvidence
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 17, 2024
1 parent f7f6e10 commit 11e1691
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
10 changes: 5 additions & 5 deletions packages/fast-usdc/src/exos/operator-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const OperatorKitI = {
}),

operator: M.interface('Operator', {
submitEvidence: M.call(CctpTxEvidenceShape).returns(M.promise()),
submitEvidence: M.call(CctpTxEvidenceShape).returns(),
getStatus: M.call().returns(M.record()),
}),
};
Expand Down Expand Up @@ -87,7 +87,7 @@ export const prepareOperatorKit = (zone, staticPowers) =>
const { operator } = this.facets;
// TODO(bootstrap integration): cause this call to throw and confirm that it
// shows up in the the smart-wallet UpdateRecord `error` property
await operator.submitEvidence(evidence);
operator.submitEvidence(evidence);
return staticPowers.makeInertInvitation(
'evidence was pushed in the invitation maker call',
);
Expand All @@ -98,12 +98,12 @@ export const prepareOperatorKit = (zone, staticPowers) =>
* submit evidence from this operator
*
* @param {CctpTxEvidence} evidence
* @returns {void}
*/
async submitEvidence(evidence) {
submitEvidence(evidence) {
const { state } = this;
!state.disabled || Fail`submitEvidence for disabled operator`;
const result = state.powers.attest(evidence, this.facets);
return result;
state.powers.attest(evidence, this.facets);
},
/** @returns {OperatorStatus} */
getStatus() {
Expand Down
28 changes: 12 additions & 16 deletions packages/fast-usdc/test/exos/transaction-feed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ test('happy aggregation', async t => {

const { op1, op2, op3 } = await makeOperators(feedKit);
const evidence = MockCctpTxEvidences.AGORIC_PLUS_OSMO();
const results = await Promise.all([
op1.operator.submitEvidence(evidence),
op2.operator.submitEvidence(evidence),
op3.operator.submitEvidence(evidence),
]);
t.deepEqual(results, [undefined, undefined, undefined]);
op1.operator.submitEvidence(evidence);
op2.operator.submitEvidence(evidence);
op3.operator.submitEvidence(evidence);

const accepted = await evidenceSubscriber.getUpdateSince(0);
t.deepEqual(accepted, {
Expand All @@ -62,18 +59,17 @@ test('happy aggregation', async t => {
});

// verify that it doesn't publish until three match
await Promise.all([
// once it publishes, it doesn't remember that it already saw these
op1.operator.submitEvidence(evidence),
op2.operator.submitEvidence(evidence),
// but this time the third is different
op3.operator.submitEvidence(MockCctpTxEvidences.AGORIC_PLUS_DYDX()),
]);
// once it publishes, it doesn't remember that it already saw these
op1.operator.submitEvidence(evidence);
op2.operator.submitEvidence(evidence);
// but this time the third is different
op3.operator.submitEvidence(MockCctpTxEvidences.AGORIC_PLUS_DYDX());

t.like(await evidenceSubscriber.getUpdateSince(0), {
// Update count is still 1
updateCount: 1n,
});
await op3.operator.submitEvidence(evidence);
op3.operator.submitEvidence(evidence);
t.like(await evidenceSubscriber.getUpdateSince(0), {
updateCount: 2n,
});
Expand All @@ -85,11 +81,11 @@ test('disabled operator', async t => {
const evidence = MockCctpTxEvidences.AGORIC_PLUS_OSMO();

// works before disabling
await op1.operator.submitEvidence(evidence);
op1.operator.submitEvidence(evidence);

op1.admin.disable();

await t.throwsAsync(() => op1.operator.submitEvidence(evidence), {
t.throws(() => op1.operator.submitEvidence(evidence), {
message: 'submitEvidence for disabled operator',
});
});
Expand Down

0 comments on commit 11e1691

Please sign in to comment.