-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update Upgrade and add upgrade tests #36
Conversation
Leonard-Pat
commented
Jun 20, 2024
•
edited
Loading
edited
- Remove gift_status
- Update upgrade methods
- added upgrade tests
Can you remove the |
done - very weird i dont know where the file came from 😄 |
Co-authored-by: gaetbout <[email protected]>
tests-integration/upgrade.test.ts
Outdated
|
||
it("Upgrade: Too Early", async function () { | ||
const { factory } = await setupGiftProtocol(); | ||
const newFactoryClassHash = await manager.declareFixtureContract("GiftFactoryUpgrade"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need to declare that fixture to test this behavior, but that's nitpick, feel free to just ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/contracts/timelock_upgrade.cairo
Outdated
@@ -66,12 +72,13 @@ pub mod TimelockUpgradeComponent { | |||
#[derive(Drop, starknet::Event)] | |||
struct UpgradeProposed { | |||
new_implementation: ClassHash, | |||
ready_at: u64 | |||
ready_at: u64, | |||
calldata_hash: felt252 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but maybe the event should also emit the calldata_array instead of the hash, or even on top of the hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to just emit the calldata, is that better ?
await factory.get_calldata_hash().should.eventually.equal(BigInt(hash.computePoseidonHashOnElements(calldata))); | ||
|
||
await manager.increaseTime(MIN_SECURITY_PERIOD + 1n); | ||
await factory.upgrade(calldata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'd tend to avoid increaseTime tbh. I just changed this bit from
await manager.increaseTime(MIN_SECURITY_PERIOD + 1n);
to await manager.increaseTime(MIN_SECURITY_PERIOD);
and it passes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all increase time removed
.gitignore
Outdated
dist | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an empty line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mean the one at line 46, not the one at the bottom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay updated
Co-authored-by: gaetbout <[email protected]>
Co-authored-by: gaetbout <[email protected]>
tests-integration/upgrade.test.ts
Outdated
await expectRevertWithErrorMessage("upgrade/upgrade-too-late", () => factory.upgrade([])); | ||
}); | ||
|
||
it("Propose: implementation-null", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: rename all "Propose" and use a describe("Propose") instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests-integration/upgrade.test.ts
Outdated
}); | ||
}); | ||
|
||
it("Cancel Upgrade /w events", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as prev Nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done