Skip to content

Commit

Permalink
fix chain/transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 23, 2024
1 parent ef177a2 commit 17406c4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion chain/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func BuildBlock(
txsAttempted = 0
results = []*Result{}

vdrState = vm.ValidatorState()
sm = vm.StateManager()

// prepareStreamLock ensures we don't overwrite stream prefetching spawned
Expand Down
2 changes: 0 additions & 2 deletions chain/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ package chain

import (
"context"
"errors"
"fmt"

"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/ids"

"github.com/ava-labs/hypersdk/codec"
Expand Down
6 changes: 3 additions & 3 deletions codec/type_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func (p *TypeParser[T, Y]) Register(id uint8, f func(*Packer) (T, error), y Y) e

// LookupIndex returns the decoder function and success of lookup of [index]
// from Typeparser [p].
func (p *TypeParser[T, Y]) LookupIndex(index uint8) (func(*Packer) (T, error), Y, bool) {
func (p *TypeParser[T, Y]) LookupIndex(index uint8) (func(*Packer) (T, error), bool) {
d, ok := p.indexToDecoder[index]
if ok {
return d.f, d.y, true
return d.f, true
}
return nil, *new(Y), false
return nil, false
}
9 changes: 3 additions & 6 deletions codec/type_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ func TestTypeParser(t *testing.T) {

t.Run("empty parser", func(t *testing.T) {
require := require.New(t)
f, b, ok := tp.LookupIndex(0)
f, ok := tp.LookupIndex(0)
require.Nil(f)
require.False(ok)
require.False(b)
})

t.Run("populated parser", func(t *testing.T) {
Expand All @@ -66,16 +65,14 @@ func TestTypeParser(t *testing.T) {
),
)

f, b, ok := tp.LookupIndex(blah1.GetTypeID())
f, ok := tp.LookupIndex(blah1.GetTypeID())
require.True(ok)
require.True(b)
res, err := f(nil)
require.Nil(res)
require.ErrorIs(err, errBlah1)

f, b, ok = tp.LookupIndex(blah2.GetTypeID())
f, ok = tp.LookupIndex(blah2.GetTypeID())
require.True(ok)
require.False(b)
res, err = f(nil)
require.Nil(res)
require.ErrorIs(err, errBlah2)
Expand Down

0 comments on commit 17406c4

Please sign in to comment.