mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
0c91bfbf3e
* clean * save * pubsub * pubsub * pubsub * pubsub * pubsub * pubsub * save * tx pub-sub * tx pub-sub * clean * clean * save * save * save * save * save * Squashed 'interfaces/' content from commit c469f3ae0 git-subtree-dir: interfaces git-subtree-split: c469f3ae073b60c8821b61fed2910191080ef835 * save * save * save * save * Squashed 'interfaces/' changes from c469f3ae0..958dfc669 958dfc669 save git-subtree-dir: interfaces git-subtree-split: 958dfc669f8daeefe686a13aa852fb95f1537886 * save * save * up some deps * up some deps * clean * test * test * test * test * test * test * test * test * test * test * test * test
63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
"github.com/ledgerwatch/turbo-geth/rpc"
|
|
)
|
|
|
|
func TestEmptyQuery(t *testing.T) {
|
|
db, err := createTestKV()
|
|
if err != nil {
|
|
t.Fatalf("create test db: %v", err)
|
|
}
|
|
defer db.Close()
|
|
api := NewTraceAPI(NewBaseApi(nil), db, &cli.Flags{})
|
|
// Call GetTransactionReceipt for transaction which is not in the database
|
|
var latest = rpc.LatestBlockNumber
|
|
results, err := api.CallMany(context.Background(), json.RawMessage("[]"), &rpc.BlockNumberOrHash{BlockNumber: &latest})
|
|
if err != nil {
|
|
t.Errorf("calling CallMany: %v", err)
|
|
}
|
|
if results == nil {
|
|
t.Errorf("expected empty array, got nil")
|
|
}
|
|
if len(results) > 0 {
|
|
t.Errorf("expected empty array, got %d elements", len(results))
|
|
}
|
|
}
|
|
func TestCoinbaseBalance(t *testing.T) {
|
|
db, err := createTestKV()
|
|
if err != nil {
|
|
t.Fatalf("create test db: %v", err)
|
|
}
|
|
defer db.Close()
|
|
api := NewTraceAPI(NewBaseApi(nil), db, &cli.Flags{})
|
|
// Call GetTransactionReceipt for transaction which is not in the database
|
|
var latest = rpc.LatestBlockNumber
|
|
results, err := api.CallMany(context.Background(), json.RawMessage(`
|
|
[
|
|
[{"from":"0x71562b71999873db5b286df957af199ec94617f7","to":"0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e","gas":"0x15f90","gasPrice":"0x4a817c800","value":"0x1"},["trace", "stateDiff"]],
|
|
[{"from":"0x71562b71999873db5b286df957af199ec94617f7","to":"0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e","gas":"0x15f90","gasPrice":"0x4a817c800","value":"0x1"},["trace", "stateDiff"]]
|
|
]
|
|
`), &rpc.BlockNumberOrHash{BlockNumber: &latest})
|
|
if err != nil {
|
|
t.Errorf("calling CallMany: %v", err)
|
|
}
|
|
if results == nil {
|
|
t.Errorf("expected empty array, got nil")
|
|
}
|
|
if len(results) != 2 {
|
|
t.Errorf("expected array with 2 elements, got %d elements", len(results))
|
|
}
|
|
// Expect balance increase of the coinbase (zero address)
|
|
if _, ok := results[1].StateDiff[common.Address{}]; !ok {
|
|
t.Errorf("expected balance increase for coinbase (zero address)")
|
|
}
|
|
|
|
}
|