Skip to content

Commit

Permalink
Update contract deplyoments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 committed Oct 16, 2024
1 parent d06b3f4 commit f4819c8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
30 changes: 25 additions & 5 deletions testUnderForked/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ contract("TwapFeeHandler - [admin]", async (accounts) => {
DynamicFeeHandlerInstance = await DynamicFeeHandlerContract.new(
BridgeInstance.address,
FeeHandlerRouterInstance.address,
0,
0
);
ADMIN_ROLE = await DynamicFeeHandlerInstance.DEFAULT_ADMIN_ROLE();
Expand Down Expand Up @@ -119,21 +120,40 @@ contract("TwapFeeHandler - [admin]", async (accounts) => {
);
});

it("should set fee properties and emit 'FeePropertySet' event", async () => {
it("should set gas used property and emit 'GasUsedSet' event", async () => {
assert.equal(await DynamicFeeHandlerInstance._gasUsed.call(), "0");
const setFeeOraclePropertiesTx = await DynamicFeeHandlerInstance.setFeeProperties(gasUsed);
const setFeeOraclePropertiesTx = await DynamicFeeHandlerInstance.setGasUsed(gasUsed);
assert.equal(await DynamicFeeHandlerInstance._gasUsed.call(), gasUsed);

TruffleAssert.eventEmitted(setFeeOraclePropertiesTx, "FeePropertySet", (event) => {
TruffleAssert.eventEmitted(setFeeOraclePropertiesTx, "GasUsedSet", (event) => {
return (
event.gasUsed.toNumber() === gasUsed
);
});
});

it("should require admin role to change fee properties", async () => {
it("should require admin role to set gas used", async () => {
await assertOnlyAdmin(
DynamicFeeHandlerInstance.setFeeProperties,
DynamicFeeHandlerInstance.setGasUsed,
gasUsed
);
});

it("should set revert gas property and emit 'RecoverGasSet' event", async () => {
assert.equal(await DynamicFeeHandlerInstance._recoverGas.call(), "0");
const setRecoverGasTx = await DynamicFeeHandlerInstance.setRecoverGas(gasUsed);
assert.equal(await DynamicFeeHandlerInstance._recoverGas.call(), gasUsed);

TruffleAssert.eventEmitted(setRecoverGasTx, "RecoverGasSet", (event) => {
return (
event.recoverGas.toNumber() === gasUsed
);
});
});

it("should require admin role to set recover gas", async () => {
await assertOnlyAdmin(
DynamicFeeHandlerInstance.setRecoverGas,
gasUsed
);
});
Expand Down
3 changes: 2 additions & 1 deletion testUnderForked/calculateFeeERC20EVM.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ contract("TwapFeeHandler - [calculateFee]", async (accounts) => {
DynamicFeeHandlerInstance = await DynamicFeeHandlerContract.new(
BridgeInstance.address,
FeeHandlerRouterInstance.address,
0,
0
);
FeeHandlerRouterInstance.adminSetResourceHandler(
Expand All @@ -117,7 +118,7 @@ contract("TwapFeeHandler - [calculateFee]", async (accounts) => {
fixedProtocolFee
);
await DynamicFeeHandlerInstance.setWrapTokenAddress(destinationDomainID, MATIC_ADDRESS);
await DynamicFeeHandlerInstance.setFeeProperties(gasUsed);
await DynamicFeeHandlerInstance.setGasUsed(gasUsed);

depositData = Helpers.createERCDepositData(
100,
Expand Down
3 changes: 2 additions & 1 deletion testUnderForked/collectFeeERC20EVM.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ contract("TwapNativeTokenFeeHandler - [collectFee]", async (accounts) => {
DynamicFeeHandlerInstance = await DynamicFeeHandlerContract.new(
BridgeInstance.address,
FeeHandlerRouterInstance.address,
0,
0
);

Expand Down Expand Up @@ -127,7 +128,7 @@ contract("TwapNativeTokenFeeHandler - [collectFee]", async (accounts) => {
fixedProtocolFee
);
await DynamicFeeHandlerInstance.setWrapTokenAddress(destinationDomainID, MATIC_ADDRESS);
await DynamicFeeHandlerInstance.setFeeProperties(gasUsed);
await DynamicFeeHandlerInstance.setGasUsed(gasUsed);

await BridgeInstance.adminSetResource(
ERC20HandlerInstance.address,
Expand Down
3 changes: 2 additions & 1 deletion testUnderForked/optionalContractCall/calculateFeeERC20EVM.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ contract("TwapFeeHandler - [calculateFee]", async (accounts) => {
DynamicFeeHandlerInstance = await DynamicFeeHandlerContract.new(
BridgeInstance.address,
FeeHandlerRouterInstance.address,
0,
0
);
FeeHandlerRouterInstance.adminSetResourceHandler(
Expand All @@ -122,7 +123,7 @@ contract("TwapFeeHandler - [calculateFee]", async (accounts) => {
fixedProtocolFee
);
await DynamicFeeHandlerInstance.setWrapTokenAddress(destinationDomainID, MATIC_ADDRESS);
await DynamicFeeHandlerInstance.setFeeProperties(gasUsed);
await DynamicFeeHandlerInstance.setGasUsed(gasUsed);
});

it("should return higher fee for higher execution amount", async () => {
Expand Down

0 comments on commit f4819c8

Please sign in to comment.