Skip to content

Commit 8a0ab6d

Browse files
committed
feat: finalize contracts
1 parent d5321c8 commit 8a0ab6d

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

contracts/Token.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ contract KolektivoTTD is Ownable, Pausable, ERC20 {
5858
return _isImpactPartner[account];
5959
}
6060

61-
function pause() public onlyOwner {
61+
function pause() external onlyOwner {
6262
_pause();
6363
}
6464

65-
function unpause() public onlyOwner {
65+
function unpause() external onlyOwner {
6666
_unpause();
6767
}
6868

test/minting.test.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ describe("Minting", function () {
2020
this.token_address = token_address;
2121
});
2222

23-
it("owner is the community steward");
23+
it("owner is the community steward", async function () {
24+
expect(await this.token.owner()).to.equal(this.signers.admin.address);
25+
});
2426

2527
it("should allow the community steward to mint to themselves", async function () {
2628
const initialSupply = await this.token.totalSupply();
@@ -40,4 +42,22 @@ describe("Minting", function () {
4042
await expect(this.token.connect(nonOwner).mint(nonOwner.address, 100)).to.be.reverted;
4143
});
4244
});
45+
46+
describe("When Paused", async function () {
47+
beforeEach(async function () {
48+
const { token } = await this.loadFixture(deployTokenFixture);
49+
this.token = token;
50+
const [_, alice] = await ethers.getSigners();
51+
await this.token.connect(this.signers.admin).mint(alice.address, 100n);
52+
await this.token.connect(this.signers.admin).pause();
53+
});
54+
55+
it("cannot mint when paused", async function () {
56+
const transferAmount = 100n;
57+
const [_, bob] = await ethers.getSigners();
58+
await expect(
59+
this.token.connect(this.signers.admin).mint(bob.address, transferAmount),
60+
).to.be.revertedWithCustomError(this.token, "EnforcedPause");
61+
});
62+
});
4363
});

test/ownership.test.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ describe("Ownership", () => {
3030
expect(await this.token.owner()).to.equal(newOwner.address);
3131
});
3232

33-
it("only community steward can pause transfers");
33+
it("only community steward can pause", async function () {
34+
const [_, alice] = await ethers.getSigners();
35+
await expect(this.token.connect(this.signers.admin).pause()).to.not.be.reverted;
36+
await expect(await this.token.connect(this.signers.admin).paused()).to.be.true;
37+
await expect(this.token.connect(this.signers.admin).unpause()).to.not.be.reverted;
38+
await expect(this.token.connect(alice).pause()).to.be.reverted;
39+
await expect(this.token.connect(alice).unpause()).to.be.reverted;
40+
});
3441
});
3542
});

test/transfer.test.ts

+36-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
22
import { expect } from "chai";
33
import { ethers } from "hardhat";
44

5+
import { KolektivoTTD, KolektivoTTD__factory } from "../types";
56
import { deployTokenFixture } from "./token.fixture";
67
import { Signers } from "./types";
78

@@ -33,11 +34,45 @@ describe("Transfering", function () {
3334
});
3435
});
3536

36-
describe("Paying @ Impact Partner", function () {
37+
describe("When Paused", async function () {
38+
beforeEach(async function () {
39+
const { token } = await this.loadFixture(deployTokenFixture);
40+
this.token = token;
41+
const [_, alice] = await ethers.getSigners();
42+
await this.token.connect(this.signers.admin).mint(alice.address, 100n);
43+
await this.token.connect(this.signers.admin).pause();
44+
});
45+
46+
it("can transfer when paused", async function () {
47+
const transferAmount = 100n;
48+
const [_, alice, bob] = await ethers.getSigners();
49+
await expect(this.token.connect(alice).transfer(bob.address, transferAmount)).to.not.be.revertedWithCustomError(
50+
this.token,
51+
"EnforcedPause",
52+
);
53+
});
54+
});
55+
56+
describe("Impact Partner", function () {
3757
beforeEach(async function () {
3858
const { token, token_address } = await this.loadFixture(deployTokenFixture);
3959
this.token = token;
4060
this.token_address = token_address;
61+
const [_, partner, customer] = await ethers.getSigners();
62+
await token.connect(this.signers.admin).addPartner(partner.address);
63+
await token.connect(this.signers.admin).mint(customer.address, 100n);
64+
});
65+
66+
it("impact partners can transfer", async function () {
67+
const { token } = this;
68+
const [_, partner, customer] = await ethers.getSigners();
69+
const transferAmount = 100n;
70+
await token.connect(customer).transfer(partner.address, transferAmount);
71+
expect(await token.balanceOf(partner.address)).to.equal(transferAmount);
72+
expect(await token.balanceOf(customer.address)).to.equal(0n);
73+
await token.connect(partner).transfer(customer.address, transferAmount);
74+
expect(await token.balanceOf(partner.address)).to.equal(0n);
75+
expect(await token.balanceOf(customer.address)).to.equal(transferAmount);
4176
});
4277

4378
it("can check if a partner is valid", async function () {
@@ -52,8 +87,6 @@ describe("Transfering", function () {
5287
const { token } = this;
5388
const [_, partner, customer] = await ethers.getSigners();
5489
const transferAmount = 100n;
55-
await token.connect(this.signers.admin).addPartner(partner.address);
56-
await token.connect(this.signers.admin).mint(customer.address, transferAmount);
5790
await expect(token.connect(customer).transfer(partner.address, transferAmount))
5891
.to.emit(token, "ImpactPartnerTransfer")
5992
.withArgs(customer.address, partner.address, transferAmount);

0 commit comments

Comments
 (0)