Skip to content
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

chore(ERTP): AmountMath compare should be same as Key compare #6769

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erights
Copy link
Member

@erights erights commented Jan 10, 2023

Tests that AmountMath equality and inequality match Key equality and inequality.

Moves the arbPassable abstraction into its own tools/ file so it can be shared by tests, including potentially tests outside this package. See precedent to be set by endojs/endo#1291

While explaining the store level of abstraction to @Tyrosine22 , I mentioned that we defined the key compare on amounts to be aligned with amount compare. Then I realized that this would be a perfect subject for property-based testing. However, the current arb-amount.js is too narrow for this test to really mean anything yet. It will need to generate many more kinds of amounts.

@erights erights self-assigned this Jan 10, 2023
)
.filter(pairs => distinctLabels(pairs) && positiveCounts(pairs));

// TODO: should include many non-bag amounts too
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the TODO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from 6691-markm-max-amount to master January 10, 2023 05:07
@erights
Copy link
Member Author

erights commented Jan 13, 2023

@kriskowal I suspect the CI failure at https://github.com/Agoric/agoric-sdk/actions/runs/3880814040/jobs/6619258891 is really a bundler problem. But I have no idea how to proceed and need some help.

@erights erights changed the title chore(ERTP): AmountMath compare should be same as Key compare' chore(ERTP): AmountMath compare should be same as Key compare Jan 13, 2023
@erights erights force-pushed the markm-test-amount-key-arith branch 2 times, most recently from b8b3861 to f394f66 Compare February 28, 2023 04:42
Copy link
Member Author

@erights erights left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must fix the test along with the premise of this PR. The tests currently happen to pass anyway, but this is an unlucky accident due to the terribly limited nature of the current arb-amount.js.

Putting this PR back into Draft until this issue is fixed.

Comment on lines +8 to +22
test('amount equality iff key equality', async t => {
await fc.assert(
fc.property(fc.record({ x: arbAmount, y: arbAmount }), ({ x, y }) => {
return t.true(m.isEqual(x, y) === keyEQ(x, y));
}),
);
});

test('amount >= iff key >=', async t => {
await fc.assert(
fc.property(fc.record({ x: arbAmount, y: arbAmount }), ({ x, y }) => {
return t.true(m.isGTE(x, y) === keyGTE(x, y));
}),
);
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the premise of this PR is wrong, and these tests need to be revised to reflect that.

We currently have four kinds of Amounts:

  • nats
  • sets represented as arrays -- deprecated but widely used
  • copySets, which should be used instead of arrays representing sets
  • copyBags, for semi-fungibles

The premise of this PR is true for nats, copySets, and copyBags. But it is not true for deprecated arrays representing sets, so we need to exclude them from these tests.

(Separately, we will be deprecating copySets as well, switching all uses of arrays-representing-sets and copySets to copyBags. But this is not a concern of this PR.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #7193

@erights erights marked this pull request as draft February 28, 2023 05:33
@erights erights force-pushed the markm-test-amount-key-arith branch 2 times, most recently from 921552a to c6ca4d0 Compare March 3, 2023 23:24
@datadog-full-agoric
Copy link

datadog-full-agoric bot commented Mar 3, 2023

Datadog Report

Branch report: markm-test-amount-key-arith
Commit report: e08d3ae

agoric-sdk: 0 Failed, 0 New Flaky, 3559 Passed, 57 Skipped, 15m 22.57s Wall Time

@erights erights force-pushed the markm-test-amount-key-arith branch from c6ca4d0 to 555c6dc Compare March 20, 2023 02:22
@datadog-full-agoric
Copy link

datadog-full-agoric bot commented Mar 20, 2023

Datadog Report

Branch report: markm-test-amount-key-arith
Commit report: 5ff9784

agoric-sdk: 0 Failed, 0 New Flaky, 3762 Passed, 53 Skipped, 17m 34.91s Wall Time

@erights erights force-pushed the markm-test-amount-key-arith branch from 7f75877 to 5550551 Compare June 6, 2023 02:54
@erights
Copy link
Member Author

erights commented Sep 3, 2023

@gibson042 @FUDCo

The invariant that this PR tests is a possible reason to prefer tight pareto to loose pareto. Or maybe not. We need to think about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant