mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
d3f8b5861c
Otterscan API search methods allow the user to inform the page size. This PR adds an internal max (default == 25 results) to cap the page size, regardless of what the user asks. It also adds a `--ots.search.max.pagesize` CLI args to override this max (either in erigon and rpcdaemon binaries).
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package jsonrpc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetContractCreator(t *testing.T) {
|
|
m, _, _ := rpcdaemontest.CreateTestSentry(t)
|
|
api := NewOtterscanAPI(newBaseApiForTest(m), m.DB, 25)
|
|
|
|
addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44")
|
|
expectCreator := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
|
|
expectCredByTx := libcommon.HexToHash("0x6e25f89e24254ba3eb460291393a4715fd3c33d805334cbd05c1b2efe1080f18")
|
|
t.Run("valid inputs", func(t *testing.T) {
|
|
require := require.New(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) {
|
|
require := require.New(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) {
|
|
require := require.New(t)
|
|
results, err := api.GetContractCreator(m.Ctx, expectCreator)
|
|
require.NoError(err)
|
|
require.Nil(results)
|
|
})
|
|
}
|