Skip to content

Commit

Permalink
chore: update test to use existing function
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy committed Jul 23, 2024
1 parent 8a07847 commit 0e100b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
20 changes: 0 additions & 20 deletions contracts/test/TestRpcCompatibility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ contract TestRpcCompatibility {

event ValueUpdated(uint256 indexed value);
event ValueUpdatedForSubscribe(uint256 indexed value);
event ContractCallWithToken(
address indexed sender,
string destinationChain,
string destinationContractAddress,
bytes32 indexed payloadHash,
bytes payload,
string symbol,
uint256 amount
);

function getValue() public view returns (uint256) {
return value;
Expand All @@ -30,15 +21,4 @@ contract TestRpcCompatibility {
subscribeValue = newValue;
emit ValueUpdatedForSubscribe(newValue);
}

function emitCallContractWithToken(
string calldata destinationChain,
string calldata destinationContractAddress,
bytes32 payloadHash,
bytes calldata payload,
string calldata symbol,
uint256 amount
) external {
emit ContractCallWithToken(msg.sender, destinationChain, destinationContractAddress, payloadHash, payload, symbol, amount);
}
}
15 changes: 4 additions & 11 deletions test/RpcCompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,21 +385,14 @@ describe('RpcCompatibility', () => {
});

it('should match the fetched logIndex value', async function () {
const destinationChain = 'Ethereum';
const destinationContractAddress = '0x0000000000000000000000000000000000000001';
const payload = '0x01';
const payloadHash = keccak256(payload);
const symbol = 'TOKEN';
const amount = 100;

const receipt = await rpcCompatibilityContract
.emitCallContractWithToken(destinationChain, destinationContractAddress, payloadHash, payload, symbol, amount)
.then((tx) => tx.wait());
const receipt = await rpcCompatibilityContract.updateValue(amount).then((tx) => tx.wait());
const logsFromReceipt = receipt.logs;

const eventSignature = id('ContractCallWithToken(address,string,string,bytes32,bytes,string,uint256)');
const eventSignature = id('ValueUpdated(uint256)');
const expectedEvent = logsFromReceipt.find((log) => log.topics[0] === eventSignature);
expect(expectedEvent, 'ContractCallWithToken event not found in logs from tx receipt').to.exist.and.to.not.be.null;
expect(expectedEvent, 'ValueUpdated event not found in logs from tx receipt').to.exist.and.to.not.be.null;

const blockNumber = '0x' + parseInt(receipt.blockNumber).toString(16);
const logsFromGetLogs = await provider.send('eth_getLogs', [
Expand All @@ -410,7 +403,7 @@ describe('RpcCompatibility', () => {
]);

const matchingEvent = logsFromGetLogs.find((log) => log.topics[0] === eventSignature);
expect(matchingEvent, 'ContractCallWithToken event not found in logs from eth_getLogs').to.not.be.null;
expect(matchingEvent, 'ValueUpdated event not found in logs from eth_getLogs').to.not.be.null;

expect(parseInt(expectedEvent.logIndex)).to.equal(
parseInt(matchingEvent.logIndex),
Expand Down

0 comments on commit 0e100b1

Please sign in to comment.