Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKALE-4983 add limit for message and test #1033

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proxy/contracts/MessageProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ abstract contract MessageProxy is AccessControlEnumerableUpgradeable, IMessagePr
virtual
{
require(connectedChains[targetChainHash].inited, "Destination chain is not initialized");
require(data.length <= 256, "Message is too long");
_authorizeOutgoingMessageSender(targetChainHash);

emit OutgoingMessage(
Expand Down
38 changes: 38 additions & 0 deletions proxy/test/MessageProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,44 @@ describe("MessageProxy", () => {
outgoingMessagesCounter.should.be.deep.equal(BigNumber.from(1));
});

it.only("should not post outgoing message with big data", async () => {
const contractAddress = messageProxyForMainnet.address;
const amount = 4;

const bytesData256 = "0x0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000";

const bytesData257 = "0x0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000" +
"00";

await caller
.postOutgoingMessageTester(messageProxyForMainnet.address, schainHash, contractAddress, bytesData257)
.should.be.rejectedWith("Destination chain is not initialized");

await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName);
await caller
.postOutgoingMessageTester(messageProxyForMainnet.address, schainHash, contractAddress, bytesData257)
.should.be.rejectedWith("Message is too long");
await caller
.postOutgoingMessageTester(messageProxyForMainnet.address, schainHash, contractAddress, bytesData256)
const outgoingMessagesCounter = BigNumber.from(
await messageProxyForMainnet.getOutgoingMessagesCounter(schainName));
outgoingMessagesCounter.should.be.deep.equal(BigNumber.from(1));
});

it("should allow schain owner to send message", async () => {
const message = "0xd2";
const schainOwner = user;
Expand Down