mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package commands
|
|
|
|
import (
|
|
"testing"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
|
|
"github.com/ledgerwatch/erigon/rpc/rpccfg"
|
|
"github.com/ledgerwatch/erigon/turbo/snapshotsync"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetContractCreator(t *testing.T) {
|
|
m, _, _ := rpcdaemontest.CreateTestSentry(t)
|
|
agg, require := m.HistoryV3Components(), require.New(t)
|
|
br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots)
|
|
api := NewOtterscanAPI(NewBaseApi(nil, nil, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB)
|
|
|
|
addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44")
|
|
expectCreator := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
|
|
expectCredByTx := libcommon.HexToHash("0x6e25f89e24254ba3eb460291393a4715fd3c33d805334cbd05c1b2efe1080f18")
|
|
t.Run("valid input", func(t *testing.T) {
|
|
results, err := api.GetContractCreator(m.Ctx, addr)
|
|
require.NoError(err)
|
|
require.Equal(expectCreator, results.Creator)
|
|
require.Equal(expectCredByTx, results.Tx)
|
|
})
|
|
t.Run("not existing addr", func(t *testing.T) {
|
|
results, err := api.GetContractCreator(m.Ctx, libcommon.HexToAddress("0x1234"))
|
|
require.NoError(err)
|
|
require.Nil(results)
|
|
})
|
|
t.Run("pass creator as addr", func(t *testing.T) {
|
|
results, err := api.GetContractCreator(m.Ctx, expectCreator)
|
|
require.NoError(err)
|
|
require.Nil(results)
|
|
})
|
|
}
|