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

Update Upgrade and add upgrade tests #36

Merged
merged 29 commits into from
Jun 25, 2024
Merged

Conversation

Leonard-Pat
Copy link
Contributor

@Leonard-Pat Leonard-Pat commented Jun 20, 2024

  • Remove gift_status
  • Update upgrade methods
  • added upgrade tests

@Leonard-Pat Leonard-Pat changed the title Upgrade and Gift Status Tests Update Upgrade and add upgrade tests Jun 21, 2024
@Leonard-Pat Leonard-Pat marked this pull request as ready for review June 24, 2024 07:58
@Leonard-Pat Leonard-Pat requested review from sgc-code and gaetbout June 24, 2024 07:58
@gaetbout
Copy link
Contributor

Can you remove the .DS_STORE file?

@Leonard-Pat
Copy link
Contributor Author

Can you remove the .DS_STORE file?

done - very weird i dont know where the file came from 😄

lib/protocol.ts Outdated Show resolved Hide resolved

it("Upgrade: Too Early", async function () {
const { factory } = await setupGiftProtocol();
const newFactoryClassHash = await manager.declareFixtureContract("GiftFactoryUpgrade");
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -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
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 but maybe the event should also emit the calldata_array instead of the hash, or even on top of the hash?

Copy link
Contributor Author

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);
Copy link
Contributor

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all increase time removed

@Leonard-Pat Leonard-Pat requested a review from gaetbout June 25, 2024 11:06
.gitignore Outdated
dist

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-06-25 at 12 34 16 but now it shows this (Axel told me to always add an emtpy line but idm)

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay updated

lib/claim.ts Show resolved Hide resolved
await expectRevertWithErrorMessage("upgrade/upgrade-too-late", () => factory.upgrade([]));
});

it("Propose: implementation-null", async function () {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

});
});

it("Cancel Upgrade /w events", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as prev Nit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Leonard-Pat Leonard-Pat merged commit 3282203 into develop Jun 25, 2024
5 checks passed
@Leonard-Pat Leonard-Pat deleted the test/missing-tests branch June 25, 2024 12:11
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.

3 participants