From 8c5de488c73d3477089aa792c46ee90650ca0662 Mon Sep 17 00:00:00 2001 From: nick Date: Sat, 7 Dec 2024 22:01:36 +0900 Subject: [PATCH] fix: fix test --- node/pkg/chain/helper/helper.go | 7 ++++++- node/pkg/chain/noncemanagerv2/noncemanagerv2.go | 15 --------------- node/pkg/chain/tests/chain_test.go | 1 - node/script/test_dal_consumer/main.go | 4 ++-- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/node/pkg/chain/helper/helper.go b/node/pkg/chain/helper/helper.go index eccd17ec0..c2be81e39 100644 --- a/node/pkg/chain/helper/helper.go +++ b/node/pkg/chain/helper/helper.go @@ -200,7 +200,12 @@ func (t *ChainHelper) SubmitDelegatedFallbackDirect(ctx context.Context, contrac tx, err = t.GetSignedFromDelegator(tx) if err != nil { - return t.SubmitDirect(ctx, contractAddress, functionString, args...) + tx, err = utils.MakeDirectTx(ctx, t.client, contractAddress, t.wallet, functionString, t.chainID, nonce, args...) + if err != nil { + return err + } + + return utils.SubmitRawTx(ctx, t.client, tx) } return utils.SubmitRawTx(ctx, t.client, tx) diff --git a/node/pkg/chain/noncemanagerv2/noncemanagerv2.go b/node/pkg/chain/noncemanagerv2/noncemanagerv2.go index 116a20b06..aebba2469 100644 --- a/node/pkg/chain/noncemanagerv2/noncemanagerv2.go +++ b/node/pkg/chain/noncemanagerv2/noncemanagerv2.go @@ -34,55 +34,40 @@ func (m *NonceManagerV2) GetNonce(ctx context.Context, address string) (uint64, defer m.mu.Unlock() if _, ok := m.noncePool[address]; !ok { - log.Debug().Msgf("Initializing nonce pool for address %s", address) m.noncePool[address] = make(chan uint64, 30) if err := m.unsafeRefill(ctx, address); err != nil { return 0, err } - log.Debug().Msgf("Nonce pool initialized for address %s", address) } - - log.Debug().Msgf("Checking nonce pool for address %s", address) if len(m.noncePool[address]) < minimumNoncePoolSize { - log.Debug().Msgf("Low nonce pool size for address %s, refilling...", address) if err := m.unsafeRefill(ctx, address); err != nil { return 0, fmt.Errorf("failed to refill nonce pool: %w", err) } - log.Debug().Msgf("Nonce pool refilled for address %s", address) } - log.Debug().Msgf("Getting nonce from pool for address %s", address) - nonce := <-m.noncePool[address] return nonce, nil } func (m *NonceManagerV2) unsafeRefill(ctx context.Context, address string) error { - log.Debug().Msgf("refilling nonce pool for address %s", address) currentNonce, err := utils.GetNonceFromPk(ctx, address, m.client) if err != nil { return err } - log.Debug().Msgf("current nonce for address %s: %d", address, currentNonce) - m.unsafeFlushPool(address) for i := uint64(0); i < poolSize; i++ { m.noncePool[address] <- currentNonce + i - log.Debug().Msgf("added nonce %d to pool for address %s", currentNonce+i, address) } return nil } func (m *NonceManagerV2) unsafeFlushPool(address string) { - log.Debug().Msgf("flushing nonce pool for address %s", address) if pool, exists := m.noncePool[address]; exists { for len(pool) > 0 { <-pool } } - - log.Debug().Msgf("nonce pool flushed for address %s", address) } func (m *NonceManagerV2) refillAll(ctx context.Context) error { diff --git a/node/pkg/chain/tests/chain_test.go b/node/pkg/chain/tests/chain_test.go index 7f78cbe5b..b8c8b63e6 100644 --- a/node/pkg/chain/tests/chain_test.go +++ b/node/pkg/chain/tests/chain_test.go @@ -240,7 +240,6 @@ func TestGenerateViewABI(t *testing.T) { } func TestSubmitDelegeted(t *testing.T) { - t.Skip() ctx := context.Background() kaiaHelper, err := helper.NewChainHelper(ctx) diff --git a/node/script/test_dal_consumer/main.go b/node/script/test_dal_consumer/main.go index 8006617a5..463e839dd 100644 --- a/node/script/test_dal_consumer/main.go +++ b/node/script/test_dal_consumer/main.go @@ -74,7 +74,7 @@ func main() { proofs = append(proofs, klaytncommon.Hex2Bytes(strings.TrimPrefix(entry.Proof, "0x"))) if len(feedHashes) >= 50 { - err = kaiaHelper.SubmitDelegatedFallbackDirect(ctx, contractAddr, SUBMIT_STRICT, maxTxSubmissionRetries, feedHashes, values, timestamps, proofs) + err = kaiaHelper.SubmitDelegatedFallbackDirect(ctx, contractAddr, SUBMIT_STRICT, feedHashes, values, timestamps, proofs) if err != nil { log.Error().Err(err).Msg("MakeDirect") panic(err) @@ -87,7 +87,7 @@ func main() { } } - err = kaiaHelper.SubmitDelegatedFallbackDirect(ctx, contractAddr, SUBMIT_STRICT, maxTxSubmissionRetries, feedHashes, values, timestamps, proofs) + err = kaiaHelper.SubmitDelegatedFallbackDirect(ctx, contractAddr, SUBMIT_STRICT, feedHashes, values, timestamps, proofs) if err != nil { log.Error().Err(err).Msg("MakeDirect") panic(err)