-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d5a7b3b
commit 1e715f5
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
const {assert, expect} = require("chai"); | ||
import {ScillaContract} from "hardhat-scilla-plugin"; | ||
import {parallelizer} from "../../helpers"; | ||
const { createHash } = require('crypto'); | ||
|
||
describe("Codehash contract", () => { | ||
let expectedCodeHash: string | ||
let contract: ScillaContract; | ||
it("Deploy codehash contract", async () => { | ||
contract = await parallelizer.deployScillaContract("Codehash"); | ||
expectedCodeHash = '0x' + createHash('sha256').update(contract.code).digest('hex') | ||
assert.isTrue(contract.address !== undefined); | ||
}); | ||
|
||
it("Call code hash contract - Foo transition", async () => { | ||
let tx1 = await contract.foo(contract.address!.toLowerCase()); | ||
const codeHash1 = tx1.receipt.event_logs[0].params[0].value; | ||
expect(tx1.receipt.success).equal(true); | ||
expect(expectedCodeHash).to.be.eq(codeHash1); | ||
let tx2 = await contract.foo2(contract.address!.toLowerCase()); | ||
const codeHash2 = tx2.receipt.event_logs[0].params[0].value; | ||
expect(codeHash1).to.be.eq(codeHash2); | ||
expect(expectedCodeHash).to.be.eq(codeHash2); | ||
}); | ||
}); |