Skip to content

Commit

Permalink
SimpleOperations: use const in js tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva committed Mar 20, 2018
1 parent 240e047 commit 45ec0f3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

let Migrations = artifacts.require("./Migrations.sol");
const Migrations = artifacts.require("./Migrations.sol");

module.exports = deployer => {
deployer.deploy(Migrations);
Expand Down
2 changes: 1 addition & 1 deletion migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

let SimpleOperations = artifacts.require("./SimpleOperations.sol");
const SimpleOperations = artifacts.require("./SimpleOperations.sol");

module.exports = deployer => {
deployer.deploy(SimpleOperations);
Expand Down
98 changes: 49 additions & 49 deletions test/simple_operations.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
"use strict";

let { step } = require("mocha-steps");
const { step } = require("mocha-steps");

let SimpleOperations = artifacts.require("./SimpleOperations.sol");
const SimpleOperations = artifacts.require("./SimpleOperations.sol");

contract("SimpleOperations", accounts => {
it("should initialize the contract with the parity client", async () => {
let operations = await SimpleOperations.deployed();
let owner = await operations.client("parity");
const operations = await SimpleOperations.deployed();
const owner = await operations.client("parity");

assert.equal(owner, accounts[0]);

// the creator of the operations contract should be set as the owner of the parity client
let client = await operations.clientOwner(accounts[0]);
const client = await operations.clientOwner(accounts[0]);
assert.equal(web3.toUtf8(client), "parity");
});

it("should emit a `Received` event on fallback", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.Received();
const operations = await SimpleOperations.deployed();
const watcher = operations.Received();

await operations.sendTransaction({
from: accounts[1],
value: 3,
data: web3.fromUtf8("hello"),
});

let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(events[0].args.from, accounts[1]);
Expand All @@ -35,8 +35,8 @@ contract("SimpleOperations", accounts => {
});

it("should allow the owner of a client to transfer ownership", async () => {
let operations = await SimpleOperations.new();
let watcher = operations.ClientOwnerChanged();
const operations = await SimpleOperations.new();
const watcher = operations.ClientOwnerChanged();

// only the owner of the client can transfer ownership
try {
Expand All @@ -45,25 +45,25 @@ contract("SimpleOperations", accounts => {
assert(error.message.includes("revert"));
}

let owner = await operations.client("parity");
const owner = await operations.client("parity");
assert.equal(owner, accounts[0]);

// we successfully transfer ownership of the parity client
await operations.setClientOwner(accounts[1]);

// the `client` and `clientOwner` should point to the new owner
let new_owner = await operations.client("parity");
const new_owner = await operations.client("parity");
assert.equal(new_owner, accounts[1]);

let client = await operations.clientOwner(accounts[1]);
const client = await operations.clientOwner(accounts[1]);
assert.equal(web3.toUtf8(client), "parity");

// the old owner should no longer exist in `clientOwner`
let old_client = await operations.clientOwner(accounts[0]);
const old_client = await operations.clientOwner(accounts[0]);
assert.equal(old_client.valueOf(), 0);

// it should emit a `ClientOwnerChanged` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity");
Expand All @@ -72,14 +72,14 @@ contract("SimpleOperations", accounts => {
});

step("should allow the owner of a client to add a release", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.ReleaseAdded();
const operations = await SimpleOperations.deployed();
const watcher = operations.ReleaseAdded();

let release = "0x1234560000000000000000000000000000000000000000000000000000000000";
let forkBlock = "100";
let track = "1";
let semver = "65536";
let critical = false;
const release = "0x1234560000000000000000000000000000000000000000000000000000000000";
const forkBlock = "100";
const track = "1";
const semver = "65536";
const critical = false;

// only the owner of the client can add a release
try {
Expand Down Expand Up @@ -117,11 +117,11 @@ contract("SimpleOperations", accounts => {
assert(await operations.isLatest("parity", release));

// we can get the track for this release
let new_track = await operations.track("parity", release);
const new_track = await operations.track("parity", release);
assert.equal(new_track, track);

// it should emit a `ReleaseAdded` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity");
Expand All @@ -133,12 +133,12 @@ contract("SimpleOperations", accounts => {
});

step("should allow the owner of a client to add a checksum", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.ChecksumAdded();
const operations = await SimpleOperations.deployed();
const watcher = operations.ChecksumAdded();

let release = "0x1234560000000000000000000000000000000000000000000000000000000000";
let platform = "0x1337000000000000000000000000000000000000000000000000000000000000";
let checksum = "0x1111110000000000000000000000000000000000000000000000000000000000";
const release = "0x1234560000000000000000000000000000000000000000000000000000000000";
const platform = "0x1337000000000000000000000000000000000000000000000000000000000000";
const checksum = "0x1111110000000000000000000000000000000000000000000000000000000000";

// only the owner of the client can add a release
try {
Expand All @@ -163,12 +163,12 @@ contract("SimpleOperations", accounts => {
assert.equal(new_checksum, checksum);

// the checksum should map to the release and platform
let [new_release, new_platform] = await operations.build("parity", checksum);
const [new_release, new_platform] = await operations.build("parity", checksum);
assert.equal(new_release, release);
assert.equal(new_platform, platform);

// it should emit a `ChecksumAdded` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity");
Expand All @@ -178,8 +178,8 @@ contract("SimpleOperations", accounts => {
});

step("should allow the owner of the contract to add a client", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.ClientAdded();
const operations = await SimpleOperations.deployed();
const watcher = operations.ClientAdded();

// only the owner of the contract can add a new client
try {
Expand All @@ -203,20 +203,20 @@ contract("SimpleOperations", accounts => {
assert.equal(owner, accounts[2]);

// the creator of the operations contract should be set as the owner of the parity client
let client = await operations.clientOwner(accounts[2]);
const client = await operations.clientOwner(accounts[2]);
assert.equal(web3.toUtf8(client), "parity-light");

// it should emit a `ClientAdded` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity-light");
assert.equal(events[0].args.owner, owner);
});

step("should allow the owner of the contract to reset the client owner", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.ClientOwnerChanged();
const operations = await SimpleOperations.deployed();
const watcher = operations.ClientOwnerChanged();

// only the owner of the contract can reset the client owner
try {
Expand All @@ -229,25 +229,25 @@ contract("SimpleOperations", accounts => {
assert(error.message.includes("revert"));
}

let owner = await operations.client("parity-light");
const owner = await operations.client("parity-light");
assert.equal(owner, accounts[2]);

// we successfully reset ownership of the parity-light client
await operations.resetClientOwner("parity-light", accounts[1]);

// the `client` and `clientOwner` should point to the new owner
let new_owner = await operations.client("parity-light");
const new_owner = await operations.client("parity-light");
assert.equal(new_owner, accounts[1]);

let client = await operations.clientOwner(accounts[1]);
const client = await operations.clientOwner(accounts[1]);
assert.equal(web3.toUtf8(client), "parity-light");

// the old owner should no longer exist in `clientOwner`
let old_client = await operations.clientOwner(accounts[2]);
const old_client = await operations.clientOwner(accounts[2]);
assert.equal(old_client.valueOf(), 0);

// it should emit a `ClientOwnerChanged` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity-light");
Expand All @@ -256,8 +256,8 @@ contract("SimpleOperations", accounts => {
});

step("should allow the owner of the contract to remove a client", async () => {
let operations = await SimpleOperations.deployed();
let watcher = operations.ClientRemoved();
const operations = await SimpleOperations.deployed();
const watcher = operations.ClientRemoved();

// only the owner of the contract can remove a client
try {
Expand All @@ -279,19 +279,19 @@ contract("SimpleOperations", accounts => {
assert.equal(owner, 0);

// the creator of the operations contract should be set as the owner of the parity client
let client = await operations.clientOwner(accounts[2]);
const client = await operations.clientOwner(accounts[2]);
assert.equal(client, 0);

// it should emit a `ClientRemoved` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(web3.toUtf8(events[0].args.client), "parity-light");
});

it("should allow the owner of the contract to transfer ownership of the contract", async () => {
let operations = await SimpleOperations.new();
let watcher = operations.OwnerChanged();
const operations = await SimpleOperations.new();
const watcher = operations.OwnerChanged();

// only the owner of the contract can transfer ownership
try {
Expand All @@ -311,7 +311,7 @@ contract("SimpleOperations", accounts => {
assert.equal(owner, accounts[1]);

// it should emit a `OwnerChanged` event
let events = await watcher.get();
const events = await watcher.get();

assert.equal(events.length, 1);
assert.equal(events[0].args.old, accounts[0]);
Expand Down

0 comments on commit 45ec0f3

Please sign in to comment.