Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Add tests for ethapi #455

Merged
merged 6 commits into from Apr 10, 2020
Merged

Add tests for ethapi #455

merged 6 commits into from Apr 10, 2020

Conversation

ghost
Copy link

@ghost ghost commented Apr 1, 2020

Tests for ethapi module methods.

nonceLock := new(AddrLocker)
api := NewPrivateAccountAPI(b, nonceLock)
assert.NotPanics(t, func() {
api.DeriveAccount("https://test.ru", "/test", nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of api.DeriveAccount is not checked (from errcheck)

api.am = b.AM

addr, _ := api.NewAccount("1234")
api.ImportRawKey("11223344556677889900aabbccddff0011223344556677889900aabbccddff00", "1234")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of api.ImportRawKey is not checked (from errcheck)


api := NewPublicBlockChainAPI(b)
assert.NotPanics(t, func() {
api.Call(ctx, CallArgs{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of api.Call is not checked (from errcheck)

balance := &hexutil.Big{}

assert.NotPanics(t, func() {
DoCall(ctx, b, CallArgs{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of DoCall is not checked (from errcheck)

assert.NotPanics(t, func() {
b.Returned("StateAndHeaderByNumber", nil, nil)
b.Error("StateAndHeaderByNumber", ErrBackendTest)
DoCall(ctx, b, CallArgs{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of DoCall is not checked (from errcheck)

func (b *testBackend) Returned(method string, args ...interface{}) {
b.result.err[method] = nil
b.result.panic[method] = ""
b.result.returned[method] = make([]interface{}, len(args), len(args))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1019: should use make([]interface{}, len(args)) instead (from gosimple)

}

func (w *testWallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
return make([]byte, 128, 128), nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1019: should use make([]byte, 128) instead (from gosimple)

}

func (w *testWallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
return make([]byte, 128, 128), nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1019: should use make([]byte, 128) instead (from gosimple)

}

func (w *testWallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
return make([]byte, 128, 128), nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1019: should use make([]byte, 128) instead (from gosimple)

b.result.err[method] = nil
b.result.panic[method] = ""
b.result.returned[method] = make([]interface{}, len(args), len(args))
for i, v := range args {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1001: should use copy() instead of a loop (from gosimple)

@codecov-io
Copy link

Codecov Report

Merging #455 into develop will decrease coverage by 0.56%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #455      +/-   ##
===========================================
- Coverage    44.36%   43.80%   -0.57%     
===========================================
  Files          168      171       +3     
  Lines        11637    11874     +237     
===========================================
+ Hits          5163     5201      +38     
- Misses        6063     6248     +185     
- Partials       411      425      +14     
Impacted Files Coverage Δ
app/store_migration.go 0.00% <0.00%> (-70.74%) ⬇️
cmd/lachesis/config_migrations.go 65.78% <0.00%> (-34.22%) ⬇️
app/config.go 31.57% <0.00%> (-18.43%) ⬇️
gossip/store_migration.go 71.42% <0.00%> (-6.35%) ⬇️
app/store.go 29.41% <0.00%> (-4.71%) ⬇️
integration/assembly.go 62.22% <0.00%> (-1.61%) ⬇️
evmcore/tx_pool.go 76.16% <0.00%> (-0.83%) ⬇️
gossip/apply_genesis.go 67.30% <0.00%> (-0.70%) ⬇️
utils/migration/migration.go 81.39% <0.00%> (-0.43%) ⬇️
gossip/store.go 66.29% <0.00%> (-0.38%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6145da3...a89a17c. Read the comment docs.

@devintegral devintegral merged commit be341e8 into Fantom-foundation:develop Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants