mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
import { expect } from "chai";
|
|
import { ethers } from "hardhat";
|
|
import { Contract, Signer } from "ethers";
|
|
import { IWarpMessenger } from "typechain-types";
|
|
|
|
// LP-aligned address: P=6 (LP-6xxx Bridges), C=2 (C-Chain), II=01 (Warp)
|
|
const WARP_ADDRESS = "0x0000000000000000000000000000000000016201";
|
|
let senderAddress = process.env["SENDER_ADDRESS"];
|
|
// Expected to be a hex string
|
|
let payload = process.env["PAYLOAD"];
|
|
let expectedUnsignedMessage = process.env["EXPECTED_UNSIGNED_MESSAGE"];
|
|
let sourceID = process.env["SOURCE_CHAIN_ID"];
|
|
|
|
describe("IWarpMessenger", function () {
|
|
let owner: Signer;
|
|
let contract: IWarpMessenger;
|
|
before(async function () {
|
|
owner = await ethers.getSigner(senderAddress);
|
|
contract = await ethers.getContractAt("IWarpMessenger", WARP_ADDRESS, owner)
|
|
});
|
|
|
|
it("contract should be to send warp message", async function () {
|
|
console.log(`Sending warp message with payload ${payload}, expected unsigned message ${expectedUnsignedMessage}`);
|
|
|
|
// Get ID of payload by taking sha256 of unsigned message
|
|
let messageID = ethers.sha256(expectedUnsignedMessage);
|
|
let tx = await contract.sendWarpMessage(payload)
|
|
let receipt = await tx.wait()
|
|
await expect(receipt)
|
|
.to.emit(contract, 'SendWarpMessage')
|
|
.withArgs(senderAddress, messageID, expectedUnsignedMessage);
|
|
})
|
|
|
|
it("should be able to fetch correct blockchain ID", async function () {
|
|
let blockchainID = await contract.getBlockchainID();
|
|
expect(blockchainID).to.be.equal(sourceID);
|
|
})
|
|
})
|