-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathsample-test.js
More file actions
38 lines (36 loc) · 1.55 KB
/
Copy pathsample-test.js
File metadata and controls
38 lines (36 loc) · 1.55 KB
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
32
33
34
35
36
37
38
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("Transactions", function () {
let transactions
beforeEach( async()=>{
const Transactions = await ethers.getContractFactory("Transactions");
transactions = await Transactions.deploy();
})
it("Should reject zero address", async function () {
// await transactions.deployed();
const zeroAddress = ethers.ZeroAddress
// await expect(transactions.addToBlockchain(zeroAddress, 300,"message", "keyword")).to.be.revertedWithCustomError(transactions,"Transactions__InvalidReceiver")
// Note: Changed the error checking syntax
await expect(
transactions.addToBlockchain(
ethers.constants.AddressZero, // Invalid address
100, "Hello", "Test"
)
).to.be.revertedWith("Invalid receiver address");
});
it("Should reject zero amount", async function () {
const Transactions = await ethers.getContractFactory("Transactions");
transactions = await Transactions.deploy();
// await transactions.deployed();
const zeroAddress = ethers.ZeroAddress
// await expect(transactions.addToBlockchain(zeroAddress, 300,"message", "keyword")).to.be.revertedWithCustomError(transactions,"Transactions__InvalidReceiver")
// Note: Changed the error checking syntax
const address = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
await expect(
transactions.addToBlockchain(
address,
0, "Hello", "Test"
)
).to.be.revertedWith("Amount must be greater than 0");
});
});