forked from trufflesuite/webinar-episode-01
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_storage.js
31 lines (27 loc) · 1.02 KB
/
simple_storage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const SimpleStorage = artifacts.require("SimpleStorage");
contract("SimpleStorage", function (accounts) {
describe("Initial deployment", async () => {
it("should assert true", async function () {
await SimpleStorage.deployed();
assert.isTrue(true);
});
it("was deployed and it's intial value is 0", async () => {
// get subject
const ssInstance = await SimpleStorage.deployed();
// verify it starts with zero
const storedData = await ssInstance.getStoredData.call();
assert.equal(storedData, 0, `Initial state should be zero`);
});
});
describe("Functionality", () => {
it("should store the value 42", async () => {
// get subject
const ssInstance = await SimpleStorage.deployed();
// change the subject
await ssInstance.setStoredData(42, { from: accounts[0] });
// verify we changed the subject
const storedData = await ssInstance.getStoredData.call();
assert.equal(storedData, 42, `${storedData} was not stored!`);
});
});
});