Skip to content

Commit

Permalink
Rebalancer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Apr 5, 2024
1 parent 0ea8157 commit d84ce05
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
30 changes: 15 additions & 15 deletions core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func Test_l1ToL2Bridge_Close(t *testing.T) {
},
false,
func(t *testing.T, f fields) {
f.l1LogPoller.On("UnregisterFilter", f.l1FilterName).Return(nil)
f.l2LogPoller.On("UnregisterFilter", f.l2FilterName).Return(nil)
f.l1LogPoller.On("UnregisterFilter", mock.Anything, f.l1FilterName).Return(nil)
f.l2LogPoller.On("UnregisterFilter", mock.Anything, f.l2FilterName).Return(nil)
},
func(t *testing.T, f fields) {
f.l1LogPoller.AssertExpectations(t)
Expand All @@ -151,8 +151,8 @@ func Test_l1ToL2Bridge_Close(t *testing.T) {
},
true,
func(t *testing.T, f fields) {
f.l1LogPoller.On("UnregisterFilter", f.l1FilterName).Return(errors.New("unregister error"))
f.l2LogPoller.On("UnregisterFilter", f.l2FilterName).Return(nil)
f.l1LogPoller.On("UnregisterFilter", mock.Anything, f.l1FilterName).Return(errors.New("unregister error"))
f.l2LogPoller.On("UnregisterFilter", mock.Anything, f.l2FilterName).Return(nil)
},
func(t *testing.T, f fields) {
f.l1LogPoller.AssertExpectations(t)
Expand All @@ -172,8 +172,8 @@ func Test_l1ToL2Bridge_Close(t *testing.T) {
},
true,
func(t *testing.T, f fields) {
f.l1LogPoller.On("UnregisterFilter", f.l1FilterName).Return(nil)
f.l2LogPoller.On("UnregisterFilter", f.l2FilterName).Return(errors.New("unregister error"))
f.l1LogPoller.On("UnregisterFilter", mock.Anything, f.l1FilterName).Return(nil)
f.l2LogPoller.On("UnregisterFilter", mock.Anything, f.l2FilterName).Return(errors.New("unregister error"))
},
func(t *testing.T, f fields) {
f.l1LogPoller.AssertExpectations(t)
Expand Down Expand Up @@ -1181,13 +1181,13 @@ func Test_l1ToL2Bridge_getLogs(t *testing.T) {
},
func(t *testing.T, f fields, a args) {
f.l1LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l1Rebalancer.Address(),
LiquidityTransferredToChainSelectorTopicIndex,
[]common.Hash{toHash(remoteSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return(nil, errors.New("error"))
},
func(t *testing.T, f fields) {
Expand Down Expand Up @@ -1215,22 +1215,22 @@ func Test_l1ToL2Bridge_getLogs(t *testing.T) {
},
func(t *testing.T, f fields, a args) {
f.l1LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l1Rebalancer.Address(),
LiquidityTransferredToChainSelectorTopicIndex,
[]common.Hash{toHash(remoteSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return([]logpoller.Log{{}, {}}, nil)
f.l2LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
DepositFinalizedTopic,
l2Gateway.Address(),
DepositFinalizedToAddressTopicIndex,
[]common.Hash{common.HexToHash(l2RebalancerAddress.Hex())},
a.fromTs,
logpoller.Finalized,
mock.Anything,
).Return(nil, errors.New("error"))
},
func(t *testing.T, f fields) {
Expand Down Expand Up @@ -1259,31 +1259,31 @@ func Test_l1ToL2Bridge_getLogs(t *testing.T) {
},
func(t *testing.T, f fields, a args) {
f.l1LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l1Rebalancer.Address(),
LiquidityTransferredToChainSelectorTopicIndex,
[]common.Hash{toHash(remoteSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return([]logpoller.Log{{}, {}}, nil)
f.l2LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
DepositFinalizedTopic,
l2Gateway.Address(),
DepositFinalizedToAddressTopicIndex,
[]common.Hash{common.HexToHash(l2RebalancerAddress.Hex())},
a.fromTs,
logpoller.Finalized,
mock.Anything,
).Return([]logpoller.Log{{}, {}}, nil)
f.l2LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l2RebalancerAddress,
LiquidityTransferredFromChainSelectorTopicIndex,
[]common.Hash{toHash(localSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return(nil, errors.New("error"))
},
func(t *testing.T, f fields) {
Expand Down Expand Up @@ -1312,37 +1312,37 @@ func Test_l1ToL2Bridge_getLogs(t *testing.T) {
},
func(t *testing.T, f fields, a args) {
f.l1LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l1Rebalancer.Address(),
LiquidityTransferredToChainSelectorTopicIndex,
[]common.Hash{toHash(remoteSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return([]logpoller.Log{
{EventSig: LiquidityTransferredTopic, TxHash: common.HexToHash("0x1")},
{EventSig: LiquidityTransferredTopic, TxHash: common.HexToHash("0x2")},
}, nil)
f.l2LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
DepositFinalizedTopic,
l2Gateway.Address(),
DepositFinalizedToAddressTopicIndex,
[]common.Hash{common.HexToHash(l2RebalancerAddress.Hex())},
a.fromTs,
logpoller.Finalized,
mock.Anything,
).Return([]logpoller.Log{
{EventSig: DepositFinalizedTopic, TxHash: common.HexToHash("0x3")},
{EventSig: DepositFinalizedTopic, TxHash: common.HexToHash("0x4")},
}, nil)
f.l2LogPoller.On("IndexedLogsCreatedAfter",
mock.Anything,
LiquidityTransferredTopic,
l2RebalancerAddress,
LiquidityTransferredFromChainSelectorTopicIndex,
[]common.Hash{toHash(localSelector)},
a.fromTs,
logpoller.Confirmations(1),
mock.Anything,
).Return([]logpoller.Log{
{EventSig: LiquidityTransferredTopic, TxHash: common.HexToHash("0x5")},
{EventSig: LiquidityTransferredTopic, TxHash: common.HexToHash("0x6")},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Test_l2ToL1Bridge_getLatestNodeConfirmed(t *testing.T) {
data, err := utils.ABIEncode(`[{"type": "bytes32"}, {"type": "bytes32"}]`, want.BlockHash, want.SendRoot)
require.NoError(t, err)
rollupAddress := testutils.NewAddress()
f.l1LogPoller.On("LatestLogByEventSigWithConfs", NodeConfirmedTopic, rollupAddress, logpoller.Finalized, mock.Anything).
f.l1LogPoller.On("LatestLogByEventSigWithConfs", mock.Anything, NodeConfirmedTopic, rollupAddress, logpoller.Finalized).
Return(&logpoller.Log{
Topics: [][]byte{
NodeConfirmedTopic[:],
Expand Down Expand Up @@ -96,7 +96,7 @@ func Test_l2ToL1Bridge_getLatestNodeConfirmed(t *testing.T) {
true,
func(t *testing.T, f fields, want *arbitrum_rollup_core.ArbRollupCoreNodeConfirmed) {
rollupAddress := testutils.NewAddress()
f.l1LogPoller.On("LatestLogByEventSigWithConfs", NodeConfirmedTopic, rollupAddress, logpoller.Finalized, mock.Anything).
f.l1LogPoller.On("LatestLogByEventSigWithConfs", mock.Anything, NodeConfirmedTopic, rollupAddress, logpoller.Finalized, mock.Anything).
Return(nil, errors.New("not found"))
f.rollupCore.On("Address").Return(rollupAddress)
},
Expand Down Expand Up @@ -125,7 +125,7 @@ func Test_l2ToL1Bridge_getLatestNodeConfirmed(t *testing.T) {
data, err := utils.ABIEncode(`[{"type": "bytes32"}, {"type": "bytes32"}]`, want.BlockHash, want.SendRoot)
require.NoError(t, err)
rollupAddress := testutils.NewAddress()
f.l1LogPoller.On("LatestLogByEventSigWithConfs", NodeConfirmedTopic, rollupAddress, logpoller.Finalized, mock.Anything).
f.l1LogPoller.On("LatestLogByEventSigWithConfs", mock.Anything, NodeConfirmedTopic, rollupAddress, logpoller.Finalized, mock.Anything).
Return(&logpoller.Log{
Topics: [][]byte{
NodeConfirmedTopic[:],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func setupNodeOCR3(
},
MailMon: mailMon,
DB: db,
SqlxDB: db,
},
CSAETHKeystore: keystore,
}
Expand Down

0 comments on commit d84ce05

Please sign in to comment.