Skip to content

Instantly share code, notes, and snippets.

@NoahMarconi
Last active February 14, 2019 21:52
Show Gist options
  • Save NoahMarconi/cc58948ce86efbf325b34119df8ac9ee to your computer and use it in GitHub Desktop.
Save NoahMarconi/cc58948ce86efbf325b34119df8ac9ee to your computer and use it in GitHub Desktop.
const MetaCoin = artifacts.require("MetaCoin");
const SafeMath = artifacts.require("SafeMath");
const mode = process.env.MODE;
let metaCoinInstance;
let safeMathInstance;
contract("MetaCoin", accounts => {
beforeEach(async function() {
metaCoinInstance = await MetaCoin.new();
safeMathInstance = await SafeMath.new();
});
after("write coverage/profiler output", async () => {
if (mode === "profile") {
await global.profilerSubprovider.writeProfilerOutputAsync();
} else if (mode === "coverage") {
await global.coverageSubprovider.writeCoverageAsync();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
it("should send coin correctly", async () => {
const accountOne = accounts[0];
const accountTwo = accounts[1];
const amount = 2; // The balance of the owner (account[0]) is 1 (assigned in the constructor), so the transaction sending 2 will fail.
if (mode === "profile") {
global.profilerSubprovider.start();
}
await metaCoinInstance.sendCoin(
safeMathInstance.address,
accountTwo,
amount,
{ from: accountOne }
);
if (mode === "profile") {
global.profilerSubprovider.stop();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment