Skip to content

Commit

Permalink
fix the issue in EnqueueDepositWithdrawLSTTxs
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmyExogenous committed Dec 19, 2024
1 parent 15e5ea9 commit 0c652d1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
9 changes: 4 additions & 5 deletions testutil/batch/batch_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ func (m *Manager) EnqueueDepositWithdrawLSTTxs(batchID uint, msgType string) err
stakerId, staker.Address.String(), err)
}
assetOpFunc := func(assetId uint, _ int64, asset Asset) error {
data, err := assetsAbi.Pack(msgType, asset.ClientChainID, PaddingAddressTo32(asset.Address), PaddingAddressTo32(staker.Address), opAmount.BigInt())
if err != nil {
return xerrors.Errorf("EnqueueDepositWithdrawLSTTxs, error when call assetsAbi.Pack,err:%w", err)
}
// get the total deposit amount before deposit or withdrawal
stakerAssetInfo, err := m.QueryStakerAssetInfo(uint64(asset.ClientChainID), staker.EvmAddress().String(), asset.Address.String())
var expectedCheckValue sdkmath.Int
Expand Down Expand Up @@ -132,7 +128,10 @@ func (m *Manager) EnqueueDepositWithdrawLSTTxs(batchID uint, msgType string) err
opAmount = stakerAssetInfo.WithdrawableAmount
expectedCheckValue = stakerAssetInfo.TotalDepositAmount.Sub(opAmount)
}

data, err := assetsAbi.Pack(msgType, asset.ClientChainID, PaddingAddressTo32(asset.Address), PaddingAddressTo32(staker.Address), opAmount.BigInt())
if err != nil {
return xerrors.Errorf("EnqueueDepositWithdrawLSTTxs, error when call assetsAbi.Pack,err:%w", err)
}
err = m.enqueueTxAndSaveRecord(&EnqueueTxParams{
staker: &staker,
nonce: &nonce,
Expand Down
10 changes: 8 additions & 2 deletions testutil/batch/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ func (m *Manager) GetDB() *gorm.DB {

func (m *Manager) InitHelperRecord() error {
helperRecord, err := LoadObjectByID[HelperRecord](m.GetDB(), SqliteDefaultStartID)
logger.Info("NewManager load helper record", "err", err, "helperRecord", helperRecord)
logger.Info("InitHelperRecord load helper record", "err", err, "helperRecord", helperRecord)
batchID := uint(0)
if err == nil {
// increase the batch id, because we use a new batch id to avoid check error
// every time the test-tool is started
batchID = helperRecord.CurrentBatchID + 1
}
logger.Info("NewManager the new test batch ID is:", "batchID", batchID)
logger.Info("InitHelperRecord the new test batch ID is:", "batchID", batchID)
err = SaveObject[HelperRecord](m.GetDB(), HelperRecord{CurrentBatchID: batchID, ID: SqliteDefaultStartID})
if err != nil {
return xerrors.Errorf("can't init the helper record, err:%w", err)
Expand Down Expand Up @@ -569,6 +569,12 @@ func (m *Manager) ExecuteBatchTestForType(msgType string) error {
}

func (m *Manager) Start() error {
if err := m.Prepare(); err != nil {
return err
}
if err := m.InitHelperRecord(); err != nil {
return err
}
eg, ctx := errgroup.WithContext(m.ctx)
m.ctx = ctx
// send test transactions in batch
Expand Down
2 changes: 1 addition & 1 deletion testutil/batch/send_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (m *Manager) SignSendEvmTxAndWait(txInfo *EvmTxInQueue) error {
logger.Info(" the evm tx has been on chain but the execution is Failed", "txHash", txHash)
return xerrors.Errorf("Failed evm tx receipt, txID:%s", txHash)
}
logger.Info("the evm tx has been on chain successfully", "txID", txHash)
logger.Info("the evm tx has been on chain successfully", "blockNumber", receipt.BlockNumber, "txID", txHash)
return nil
}

Expand Down
10 changes: 8 additions & 2 deletions testutil/batch/tx_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ func (m *Manager) DepositWithdrawLSTCheck(batchID uint, msgType string) error {
"asset", asset.Name, "assetAddr", asset.Address)
transaction.CheckResult = Successful
} else {
logger.Info("DepositWithdrawLSTCheck, the check is Failed", "txID", transaction.TxHash,
logger.Error("DepositWithdrawLSTCheck, the check is Failed",
"expectedAmount", expectedCheckAmount,
"actualAmount", res.TotalDepositAmount,
"txID", transaction.TxHash,
"staker", staker.Name, "stakerAddr", staker.EvmAddress(),
"asset", asset.Name, "assetAddr", asset.Address)
transaction.CheckResult = Failed
Expand Down Expand Up @@ -232,7 +235,10 @@ func (m *Manager) EvmDelegationCheck(batchID uint, msgType string) error {
"operatorName", operator.Name, "operatorAddr", operator.AccAddress())
transaction.CheckResult = Successful
} else {
logger.Info("EvmDelegationCheck, the check is Failed", "txID", transaction.TxHash,
logger.Error("EvmDelegationCheck, the check is Failed",
"expectedAmount", expectedCheckAmount,
"actualAmount", delegatedAmount,
"txID", transaction.TxHash,
"staker", staker.Name, "stakerAddr", staker.EvmAddress(),
"asset", asset.Name, "assetAddr", asset.Address,
"operatorName", operator.Name, "operatorAddr", operator.AccAddress())
Expand Down

0 comments on commit 0c652d1

Please sign in to comment.