Skip to content

Commit 7196013

Browse files
committed
test(backend): change owner
#80
1 parent 196fef8 commit 7196013

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

backend/contracts/DistributionQueue.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pragma solidity ^0.8.28;
33

44
import { ILanguages } from "@elimu-ai/dao-contracts/ILanguages.sol";
5+
import "hardhat/console.sol";
56

67
struct Distribution {
78
string languageCode;
@@ -32,6 +33,7 @@ contract DistributionQueue {
3233
}
3334

3435
function updateOwner(address owner_) public {
36+
console.log("updateOwner");
3537
require(msg.sender == owner, "Only the current owner can set a new owner");
3638
owner = owner_;
3739
emit OwnerUpdated(owner_);
@@ -44,6 +46,7 @@ contract DistributionQueue {
4446
}
4547

4648
function updateQueueHandler(address queueHandler_) public {
49+
console.log("updateQueueHandler");
4750
require(msg.sender == owner, "Only the owner can set the `queueHandler` address");
4851
queueHandler = queueHandler_;
4952
emit QueueHandlerUpdated(queueHandler_);

backend/hardhat-gas-report.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
···································|·················|···············|·················|················|···············
1212
| addDistribution · - · - · 146,919 · 4 · - │
1313
···································|·················|···············|·················|················|···············
14+
| updateOwner · - · - · 31,213 · 1 · - │
15+
···································|·················|···············|·················|················|···············
1416
| DistributionVerifier · │
1517
···································|·················|···············|·················|················|···············
1618
| updateOwner · - · - · 27,973 · 1 · - │
@@ -47,7 +49,7 @@
4749
···································|·················|···············|·················|················|···············
4850
| Deployments · · % of limit · │
4951
···································|·················|···············|·················|················|···············
50-
| DistributionQueue · - · - · 1,012,676 · 3.4 % · - │
52+
| DistributionQueue · - · - · 1,058,635 · 3.5 % · - │
5153
···································|·················|···············|·················|················|···············
5254
| DistributionVerifier · - · - · 435,156 · 1.5 % · - │
5355
···································|·················|···············|·················|················|···············
@@ -59,7 +61,7 @@
5961
···································|·················|···············|·················|················|···············
6062
| Lock · - · - · 204,541 · 0.7 % · - │
6163
···································|·················|···············|·················|················|···············
62-
| QueueHandler · - · - · 853,631 · 2.8 % · - │
64+
| QueueHandler · - · - · 853,619 · 2.8 % · - │
6365
···································|·················|···············|·················|················|···············
6466
| SponsorshipQueue · 1,094,030 · 1,094,042 · 1,094,036 · 3.6 % · - │
6567
···································|·················|···············|·················|················|···············

backend/test/DistributionQueue.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
loadFixture,
33
} from "@nomicfoundation/hardhat-toolbox/network-helpers";
44
import { expect } from "chai";
5-
import hre from "hardhat";
5+
import hre, { ethers } from "hardhat";
66

77
describe("DistributionQueue", function () {
88
// We define a fixture to reuse the same setup in every test.
@@ -30,12 +30,20 @@ describe("DistributionQueue", function () {
3030
});
3131
});
3232

33+
describe("Update owner address", function () {
34+
it("Should change the owner", async function () {
35+
const { distributionQueue, account1, account2 } = await loadFixture(deployFixture);
36+
37+
expect(await distributionQueue.owner()).to.equal(account1.address);
38+
await distributionQueue.updateOwner(account2.address);
39+
expect(await distributionQueue.owner()).to.equal(account2.address);
40+
});
41+
});
42+
3343
describe("Update QueueHandler address", function () {
3444
it("Should change the queue handler", async function () {
3545
const { distributionQueue, account1, account2 } = await loadFixture(deployFixture);
3646

37-
console.log("account2.address:", account2.address);
38-
3947
expect(await distributionQueue.queueHandler()).to.equal(account1.address);
4048
await distributionQueue.updateQueueHandler(account2.address);
4149
expect(await distributionQueue.queueHandler()).to.equal(account2.address);

0 commit comments

Comments
 (0)