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

fixed bug updated test #215

Merged
merged 2 commits into from
Mar 27, 2024
Merged

fixed bug updated test #215

merged 2 commits into from
Mar 27, 2024

Conversation

markuspluna
Copy link
Contributor

Make emissions ungulpable pre-rzone

@markuspluna markuspluna requested a review from mootz12 March 24, 2024 09:22
@@ -159,6 +159,103 @@ pub fn create_fixture_with_data<'a>(wasm: bool) -> TestFixture<'a> {
fixture
}

/// Create a test fixture with a pool and a whale depositing and borrowing all assets
pub fn create_fixture_no_rzone_add<'a>(wasm: bool) -> TestFixture<'a> {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just perform this setup manually in the test? Creating a new fixture option for a one-off test case will likely cause more confusion down the line.

See: https://github.com/blend-capital/blend-contracts/blob/main/test-suites/tests/test_pool_inflation_attack.rs as example

@@ -40,6 +167,7 @@ fn test_emitter() {
let result = fixture.emitter.distribute();
backstop_blnd_balance += result;
assert_eq!(fixture.env.auths().len(), 0);
println!("timestamp: {}", fixture.env.ledger().timestamp());
Copy link
Contributor

Choose a reason for hiding this comment

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

println

blnd_token.balance(&fixture.backstop.address);

// Allow 6 days to pass and call distribute
// @dev: 1h1m have passed since the emitter was deployed during setup
Copy link
Contributor

Choose a reason for hiding this comment

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

this is wrong, and supports keeping the create_fixure_no_rzone_add in test.

7 days pass after creation of the fixture

1hr1m is passed for no particular reason in the create_fixture_no_rzone fn

Comment on lines 127 to 137
assert_eq!(result, (13 * 24 * 60 * 60 + 61 * 60) * 300_0000 - 300000); //pool claim is only 30% of the total emissions
let result_1 = fixture.backstop.claim(
&fixture.users[0],
&svec![&fixture.env, pool_fixture.pool.address.clone()],
&fixture.users[0],
);
assert_eq!(
result_1 + result,
(13 * 24 * 60 * 60 + 61 * 60) * SCALAR_7 - 400000
);
assert_eq!(result_1, (13 * 24 * 60 * 60 + 61 * 60) * 700_0000 - 100000);
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure i follow the
- 0_0300000, - 0_0400000 and - 0_0100000.

Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's from rounding in the emissions math

Copy link
Contributor

Choose a reason for hiding this comment

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

that is a huge number to result from rounding 😓

Comment on lines 235 to 247
// fixture.tokens[TokenIndex::STABLE].approve(
// &frodo,
// &pool_fixture.pool.address,
// &i128::MAX,
// &(fixture.env.ledger().sequence() + 100),
// );
// fixture.tokens[TokenIndex::WETH].approve(
// &frodo,
// &pool_fixture.pool.address,
// &i128::MAX,
// &(fixture.env.ledger().sequence() + 100),
// );
// fixture.tokens[TokenIndex::XLM].approve(&frodo, &pool_fixture.pool.address, &i128::MAX, &50000);
Copy link
Contributor

Choose a reason for hiding this comment

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

dead code

@mootz12 mootz12 merged commit 60be9d2 into main Mar 27, 2024
3 checks passed
@mootz12 mootz12 deleted the no-rzon-bug-fix branch March 27, 2024 13:42
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.

2 participants