Skip to content

Commit

Permalink
Add storeState NORMAL_RATCHET_SPEED update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rackstar authored and shark0der committed Oct 13, 2023
1 parent 6770622 commit 1ec77bc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unit/Ramm/storeState.js
Expand Up @@ -37,4 +37,28 @@ describe('storeState', function () {
expect(after.eth).to.be.equal(newEth);
expect(after.timestamp).to.be.equal(nextBlockTimestamp);
});
it('should update ratchetSpeed to NORMAL_RATCHET_SPEED if budget is 0', async function () {
const fixture = await loadFixture(setup);
const { ramm } = fixture.contracts;
const [member] = fixture.accounts.members;
const [governance] = fixture.accounts.governanceContracts;

// set budget to 0
const governanceSigner = await ethers.provider.getSigner(governance.address);
await ramm.connect(governanceSigner).removeBudget();
const before = await ramm.loadState();

// do a swap to trigger storeState
const ethIn = parseEther('1');
const minTokensOut = parseEther('28');
const tx = await ramm.connect(member).swap(0, minTokensOut, { value: ethIn });
await tx.wait();

const EXPECTED_NORMAL_RATCHET_SPEED = 400;
const after = await ramm.loadState();

// check storeState correctly updated ratchetSpeed
expect(before.ratchetSpeed).to.be.not.equal(EXPECTED_NORMAL_RATCHET_SPEED);
expect(after.ratchetSpeed).to.be.equal(EXPECTED_NORMAL_RATCHET_SPEED);
});
});

0 comments on commit 1ec77bc

Please sign in to comment.