Skip to content
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

Matt #4

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
farm tries to pay invalid address tests
Matthew Bartchak authored and Matthew Bartchak committed Mar 2, 2023
commit aba2be94a2fbe46cb358180e85ab97e193167af8
42 changes: 42 additions & 0 deletions test/coffee-test.js
Original file line number Diff line number Diff line change
@@ -175,5 +175,47 @@ describe("coffee contract", function () {
});

// farm tries to pay an invalid address (transactions paying all workers should revert)
describe("farm tries to pay an address that is not a worker", function () {

//test if a farm tries to pay itself
describe("farm tries to pay itself", function () {
it("Should revert with the proper error message", async function () {
//build args for payWorkers
let workers = [addr1.address, addr3.address];
let amounts = [2, 4];
let date = "02/28/2023";
//set addr1 as a farm
await hardhatCoffee.createFarm(addr1.address);

await expect(
hardhatCoffee.connect(addr1).payWorkers(workers, amounts, date, {
value: 6,
})
).to.be.reverted;
});
});

//test if a farm tries to pay a foreman
describe("farm tries to pay a foreman", function () {
it("Should revert with the proper error message", async function () {
//build args for payWorkers
let workers = [addr2.address, addr3.address];
let amounts = [2, 4];
let date = "02/28/2023";
//set addr1 as a farm
await hardhatCoffee.createFarm(addr1.address);
//set addr2 as a foreman
await hardhatCoffee.connect(addr1).createForeman(addr2.address);

await expect(
hardhatCoffee.connect(addr1).payWorkers(workers, amounts, date, {
value: 6,
})
).to.be.reverted;
});
});
});



});