diff --git a/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/ChannelManager.test.js b/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/ChannelManager.test.js deleted file mode 100644 index d888829b6..000000000 --- a/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/ChannelManager.test.js +++ /dev/null @@ -1,53 +0,0 @@ -// ChannelManager.test.js -const { expect } = require("chai"); -const { ethers } = require("hardhat"); - -describe("ChannelManager Contract", function () { - let ChannelManager; - let channelManager; - let owner; - let participant1; - let participant2; - - beforeEach(async function () { - [owner, participant1, participant2] = await ethers.getSigners(); - ChannelManager = await ethers.getContractFactory("ChannelManager"); - channelManager = await ChannelManager.deploy(); - await channelManager.deployed(); - }); - - it("should create a new state channel", async function () { - const channelAddress = await channelManager.createChannel(participant1.address, participant2.address); - const channel = await ethers.getContractAt("StateChannel", channelAddress); - - const isOpen = await channel.isOpen(); - expect(isOpen).to.be.false; // Channel should be created but not opened yet - }); - - it("should allow participants to join a channel", async function () { - const channelAddress = await channelManager.createChannel(participant1.address, participant2.address); - const channel = await ethers.getContractAt("StateChannel", channelAddress); - - await channel.connect(participant1).openChannel(); - const isOpen = await channel.isOpen(); - expect(isOpen).to.be.true; // Channel should be opened by participant1 - }); - - it("should revert when a non-participant tries to open a channel", async function () { - const channelAddress = await channelManager.createChannel(participant1.address, participant2.address); - const channel = await ethers.getContractAt("StateChannel", channelAddress); - - await expect(channel.connect(owner).openChannel()).to.be.revertedWith("Not a participant"); - }); - - it("should allow participants to close a channel", async function () { - const channelAddress = await channelManager.createChannel(participant1.address, participant2.address); - const channel = await ethers.getContractAt("StateChannel", channelAddress); - - await channel.connect(participant1).openChannel (); - await channel.connect(participant1).closeChannel(); - - const isOpen = await channel.isOpen(); - expect(isOpen).to.be.false; // Channel should be closed by participant1 - }); -}); diff --git a/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/StateChannel.test.js b/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/StateChannel.test.js deleted file mode 100644 index 17e41d481..000000000 --- a/blockchain_integration/pi_network/pi-network-layer2-scaling/tests/channels/StateChannel.test.js +++ /dev/null @@ -1,56 +0,0 @@ -// StateChannel.test.js -const { expect } = require("chai"); -const { ethers } = require("hardhat"); - -describe("StateChannel Contract", function () { - let StateChannel; - let stateChannel; - let ChannelManager; - let channelManager; - let owner; - let participant1; - let participant2; - - beforeEach(async function () { - [owner, participant1, participant2] = await ethers.getSigners(); - - ChannelManager = await ethers.getContractFactory("ChannelManager"); - channelManager = await ChannelManager.deploy(); - await channelManager.deployed(); - - StateChannel = await ethers.getContractFactory("StateChannel"); - stateChannel = await StateChannel.deploy(channelManager.address, participant1.address, participant2.address); - await stateChannel.deployed(); - }); - - it("should open a channel successfully", async function () { - await stateChannel.connect(participant1).openChannel(); - const isOpen = await stateChannel.isOpen(); - expect(isOpen).to.be.true; - }); - - it("should allow state updates", async function () { - await stateChannel.connect(participant1).openChannel(); - const newState = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("New State")); - await stateChannel.connect(participant1).updateState(newState); - - const currentState = await stateChannel.getCurrentState(); - expect(currentState).to.equal(newState); - }); - - it("should close the channel successfully", async function () { - await stateChannel.connect(participant1).openChannel(); - await stateChannel.connect(participant1).closeChannel(); - - const isOpen = await stateChannel.isOpen(); - expect(isOpen).to.be.false; - }); - - it("should revert when trying to update state after closing the channel", async function () { - await stateChannel.connect(participant1).openChannel(); - await stateChannel.connect(participant1).closeChannel(); - - const newState = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("New State")); - await expect(stateChannel.connect(participant1).updateState(newState)).to.be.revertedWith("Channel is closed"); - }); -});