fix(wallet): use mnemonic displayed check for 'findNewBlocksCommand'

Fixed some tests to use wrong sql DB for account DB
This commit is contained in:
Ivan Belyakov 2023-12-06 12:09:58 +01:00 committed by IvanBelyakoff
parent 761aa64e04
commit b8c006843b
2 changed files with 21 additions and 3 deletions

View File

@ -54,7 +54,25 @@ func (c *findNewBlocksCommand) Run(parent context.Context) (err error) {
func (c *findNewBlocksCommand) findAndSaveEthBlocks(parent context.Context, fromNum, headNum *big.Int) { func (c *findNewBlocksCommand) findAndSaveEthBlocks(parent context.Context, fromNum, headNum *big.Int) {
// Check ETH transfers for each account independently // Check ETH transfers for each account independently
mnemonicWasNotShown, err := c.accountsDB.GetMnemonicWasNotShown()
if err != nil {
c.error = err
return
}
for _, account := range c.accounts { for _, account := range c.accounts {
if mnemonicCheckEnabled && mnemonicWasNotShown {
acc, err := c.accountsDB.GetAccountByAddress(nodetypes.Address(account))
if err != nil {
c.error = err
return
}
if acc.AddressWasNotShown {
log.Info("skip findNewBlocksCommand, mnemonic has not been shown and the address has not been shared yet", "address", account)
continue
}
}
log.Debug("start findNewBlocksCommand", "account", account, "chain", c.chainClient.NetworkID(), "noLimit", c.noLimit, "from", fromNum, "to", headNum) log.Debug("start findNewBlocksCommand", "account", account, "chain", c.chainClient.NetworkID(), "noLimit", c.noLimit, "from", fromNum, "to", headNum)
headers, startBlockNum, _ := c.findBlocksWithEthTransfers(parent, account, fromNum, headNum) headers, startBlockNum, _ := c.findBlocksWithEthTransfers(parent, account, fromNum, headNum)

View File

@ -1076,7 +1076,7 @@ func TestFetchTransfersForLoadedBlocks(t *testing.T) {
address := common.HexToAddress("0x1234") address := common.HexToAddress("0x1234")
chainClient := newMockChainClient() chainClient := newMockChainClient()
tracker := transactions.NewPendingTxTracker(db, chainClient, nil, &event.Feed{}, transactions.PendingCheckInterval) tracker := transactions.NewPendingTxTracker(db, chainClient, nil, &event.Feed{}, transactions.PendingCheckInterval)
accDB, err := accounts.NewDB(wdb.client) accDB, err := accounts.NewDB(appdb)
require.NoError(t, err) require.NoError(t, err)
cmd := &loadBlocksAndTransfersCommand{ cmd := &loadBlocksAndTransfersCommand{
@ -1153,7 +1153,7 @@ func TestFetchNewBlocksCommand_findBlocksWithEthTransfers(t *testing.T) {
blockChannel := make(chan []*DBHeader, 10) blockChannel := make(chan []*DBHeader, 10)
address := common.HexToAddress("0x1234") address := common.HexToAddress("0x1234")
accDB, err := accounts.NewDB(wdb.client) accDB, err := accounts.NewDB(appdb)
require.NoError(t, err) require.NoError(t, err)
for idx, testCase := range getNewBlocksCases() { for idx, testCase := range getNewBlocksCases() {
@ -1229,7 +1229,7 @@ func TestFetchNewBlocksCommand(t *testing.T) {
address1 := common.HexToAddress("0x1234") address1 := common.HexToAddress("0x1234")
address2 := common.HexToAddress("0x5678") address2 := common.HexToAddress("0x5678")
accDB, err := accounts.NewDB(wdb.client) accDB, err := accounts.NewDB(appdb)
require.NoError(t, err) require.NoError(t, err)
tc := &TestClient{ tc := &TestClient{