-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add e2e tests #62
base: master
Are you sure you want to change the base?
Add e2e tests #62
Conversation
Removed Truffle from the project, since it was not being used, and added Waffle testing framework and the required configuration to the project. solc dependency had to be explicitly added in order to support version ^0.8.0, as the highest linked version in Waffle is ^0.6.0.
Added tests to test the operation of Tokens.
Maybe it would be better to put all e2e tests here. @xlc |
yeah I think it make sense to have this merged with the one in Acala main repo. |
Added tests to verify the correct DEX operation.
Added tests to verify the expected operation of Oracle.
Sure, I'll merge it (through a new PR) once I'm done with the tests. Should be tomorrow. |
Added tests to test the expected operation of Schedule.
dbfdf85
to
7df559a
Compare
test/Schedule.test.ts
Outdated
it("emits RescheduledCall event when rescheduling a call and executes it at a new time", async () => { | ||
const call = await dex.populateTransaction.swapWithExactSupply([ADDRESS.DOT, ADDRESS.AUSD], 200, 1); | ||
const first_target_block_number = Number(await provider.api.query.system.number()) + 5; | ||
const second_target_block_number = Number(await provider.api.query.system.number()) + 10; | ||
let iface = new ethers.utils.Interface(SCHEDULE_ABI); | ||
|
||
let current_block_number = Number(await provider.api.query.system.number()); | ||
await schedule.scheduleCall(ADDRESS.DOT, 0, 300000, 10000, 5, ethers.utils.hexlify(call.data as string)); | ||
|
||
let block_hash = await provider.api.query.system.blockHash(current_block_number); | ||
const data = await provider.api.derive.tx.events(block_hash); | ||
let event = data.events.filter(item => item.event.data.some(data => data.address == ADDRESS.Schedule && data.topics[0] == iface.getEventTopic(iface.getEvent("ScheduledCall")))); | ||
|
||
if (event.length > 0) { | ||
let log = { | ||
topics: [event[0].event.data[0].topics[0].toString(), event[0].event.data[0].topics[1].toString(), event[0].event.data[0].topics[2].toString()], data: event[0].event.data[0].data.toString() | ||
}; | ||
let decode_log = await iface.parseLog(log); | ||
await expect(schedule.rescheduleCall(7, ethers.utils.hexlify(decode_log.args.task_id))) | ||
.to.emit(schedule, "RescheduledCall") | ||
.withArgs(await wallet.getAddress(), ethers.utils.hexlify(decode_log.args.task_id)); | ||
} else { | ||
expect(false).to.be.ok; | ||
}; |
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.
@xlc @zjb0807 I could use another set of eyes on this one. For some reason, the event ScheduledCall
is never emitted and without it, I can't test the reschedule call. I went over this setup a couple of times and can't find the issue. This should pass and the setup is done in the same way as in previous examples.
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 will try
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 fixed it, you can refer to it to modify others.
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 one additional one. I updated it in a same manner you fixed this example. Thank you! 🙏
Added tests to validate the expected operation of StateRent.
Cleaned up the tests and modified the remaining Schedule example to the new way of retrieving the events.
I've been thinking about this. Maybe it would make sense to add these tests to both repositories? We have them and it's good to use them wherever we can. What do you to think @xlc and @zjb0807 ? Actually the more I think about it, the more sense it makes for the tests to be here. They will be added to AcalaNetwork/Acala repository once the reference to this repository gets updated. |
We need the tests in Acala repo so it can be ran by CI |
I could open up a PR to add the tests contained in the predeploy-contracts repository to the CI in Acala:
|
I am ok to have this merged and then we can see if we want to improve the workflow. |
Add end-to-end tests
This branch introduces tests to the predeployed contracts and migrates from Truffle to Waffle.
The changes are separated in branches:
NOTE: I'll keep this in draft until the suite is ready.