Skip to content

Commit

Permalink
remove tests for orderExecuted
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcos20 committed Aug 12, 2024
1 parent dd10e04 commit a1d6069
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions test/unit/datatokens/ERC20Template4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,77 +1564,6 @@ describe("ERC20Template4", () => {

})

it("#orderExecuted - provider should succeed to call orderExecuted on a ERC20", async () => {
const orderTxId = '0x826e9781f191ef2b4cee95eac10cfeced2bd1bd340e3f079304e3bfdd6a56106'
const providerData="some provider data"
const providerAddress = user5.address
const providerMessage = ethers.utils.solidityKeccak256(["bytes32", "bytes"], [orderTxId, ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData))]);
const providerSignature = await web3.eth.sign(providerMessage, providerAddress);
const consumerData="12345";
const consumerAddress = user2.address
const consumerMessage = ethers.utils.solidityKeccak256(['bytes'],[ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData))]);
const consumerSignature = await web3.eth.sign(consumerMessage, consumerAddress);
const tx = await erc20Token
.connect(user5)
.orderExecuted(orderTxId,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData)), providerSignature,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData)), consumerSignature, consumerAddress);
const txReceipt = await tx.wait();
let event = getEventFromTx(txReceipt, 'OrderExecuted')
assert(event, "Cannot find OrderExecuted event")
});

it("#orderExecuted - provider should fail to call orderExecuted on a ERC20 if consumerAddress == providerAddress", async () => {
const orderTxId = '0x826e9781f191ef2b4cee95eac10cfeced2bd1bd340e3f079304e3bfdd6a56106'
const providerData="some provider data"
const providerAddress = user5.address
const providerMessage = ethers.utils.solidityKeccak256(["bytes32", "bytes"], [orderTxId, ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData))]);
const providerSignature = await web3.eth.sign(providerMessage, providerAddress);
const consumerData="12345";
const consumerAddress = user5.address
const consumerMessage = ethers.utils.solidityKeccak256(['bytes'],[ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData))]);
const consumerSignature = await web3.eth.sign(consumerMessage, consumerAddress);
await expectRevert(
erc20Token.connect(user5).orderExecuted(orderTxId,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData)), providerSignature,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData)), consumerSignature, consumerAddress),
'Provider cannot be the consumer')
});
it("#orderExecuted - provider should fail to call orderExecuted on a ERC20 if consumerAddress is not the signer of consumerData", async () => {
const orderTxId = '0x826e9781f191ef2b4cee95eac10cfeced2bd1bd340e3f079304e3bfdd6a56106'
const providerData="some provider data"
const providerAddress = user5.address
const providerMessage = ethers.utils.solidityKeccak256(["bytes32", "bytes"], [orderTxId, ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData))]);
const providerSignature = await web3.eth.sign(providerMessage, providerAddress);
const consumerData="12345";
const consumerAddress = user2.address
const consumerMessage = ethers.utils.solidityKeccak256(['bytes'],[ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData))]);
const consumerSignature = await web3.eth.sign(consumerMessage, user3.address);
await expectRevert(erc20Token
.connect(user5)
.orderExecuted(orderTxId,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData)), providerSignature,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData)), consumerSignature, consumerAddress),
'Consumer signature check failed')
});
it("#orderExecuted - provider should fail to call orderExecuted on a ERC20 if msg.sender is not the signer of providerData", async () => {
const orderTxId = '0x826e9781f191ef2b4cee95eac10cfeced2bd1bd340e3f079304e3bfdd6a56106'
const providerData="some provider data"
const providerAddress = user5.address
const providerMessage = ethers.utils.solidityKeccak256(["bytes32", "bytes"], [orderTxId, ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData))]);
const providerSignature = await web3.eth.sign(providerMessage, providerAddress);
const consumerData="12345";
const consumerAddress = user2.address
const consumerMessage = ethers.utils.solidityKeccak256(['bytes'],[ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData))]);
const consumerSignature = await web3.eth.sign(consumerMessage, consumerAddress);
await expectRevert(erc20Token
.connect(user3)
.orderExecuted(orderTxId,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(providerData)), providerSignature,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(consumerData)), consumerSignature, consumerAddress),
'Provider signature check failed')
});

// sapphire specific tests
it("#getFilesObject - should be able to get the files object if there is no allow/deny list list and we have valid order", async () => {

Expand Down

0 comments on commit a1d6069

Please sign in to comment.