Skip to content

Commit

Permalink
feat: upgrade gno (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <norman@samourai.coop>
  • Loading branch information
n0izn0iz authored Nov 12, 2024
1 parent 83ec06d commit 5701299
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func getGenesisBlock(client Client) (*bft_types.Block, error) {

txs := make([]bft_types.Tx, len(genesisState.Txs))
for i, tx := range genesisState.Txs {
txs[i], err = amino.Marshal(tx)
txs[i], err = amino.Marshal(tx.Tx)
if err != nil {
return nil, fmt.Errorf("unable to marshal genesis tx: %w", err)
}
Expand Down
39 changes: 28 additions & 11 deletions fetch/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestFetcher_FetchTransactions_Valid_FullBlocks(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -357,7 +357,7 @@ func TestFetcher_FetchTransactions_Valid_FullBlocks(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -556,7 +556,7 @@ func TestFetcher_FetchTransactions_Valid_FullTransactions(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -728,7 +728,7 @@ func TestFetcher_FetchTransactions_Valid_EmptyBlocks(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -874,7 +874,7 @@ func TestFetcher_FetchTransactions_Valid_EmptyBlocks(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func TestFetcher_InvalidBlocks(t *testing.T) {
Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{
Balances: []gnoland.Balance{},
Txs: []std.Tx{},
Txs: []gnoland.TxWithMetadata{},
},
},
}, nil
Expand Down Expand Up @@ -1039,7 +1039,7 @@ func TestFetcher_Genesis(t *testing.T) {

var (
txCount = 21
txs = generateTransactions(t, txCount)
txs = generateGenesisTransactions(t, txCount)
savedBlocks = map[int64]*types.Block{}
savedTxs = map[string]*types.TxResult{}

Expand Down Expand Up @@ -1081,7 +1081,7 @@ func TestFetcher_Genesis(t *testing.T) {
return 0, nil
},
getGenesisFn: func() (*core_types.ResultGenesis, error) {
localTxs := make([]std.Tx, len(txs))
localTxs := make([]gnoland.TxWithMetadata, len(txs))
for i, tx := range txs {
localTxs[i] = *tx
}
Expand Down Expand Up @@ -1116,7 +1116,7 @@ func TestFetcher_Genesis(t *testing.T) {
expected := &types.TxResult{
Height: 0,
Index: i,
Tx: amino.MustMarshal(txs[i]),
Tx: amino.MustMarshal(txs[i].Tx),
Response: abci.ResponseDeliverTx{},
}
require.Equal(t, expected, tx)
Expand Down Expand Up @@ -1256,7 +1256,7 @@ func TestFetcher_GenesisFetchResultsError(t *testing.T) {
},
getGenesisFn: func() (*core_types.ResultGenesis, error) {
return &core_types.ResultGenesis{Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{Txs: []std.Tx{{}}},
AppState: gnoland.GnoGenesisState{Txs: []gnoland.TxWithMetadata{{}}},
}}, nil
},
getBlockResultsFn: func(uint64) (*core_types.ResultBlockResults, error) {
Expand Down Expand Up @@ -1336,7 +1336,7 @@ func TestFetcher_GenesisNilResults(t *testing.T) {
},
getGenesisFn: func() (*core_types.ResultGenesis, error) {
return &core_types.ResultGenesis{Genesis: &types.GenesisDoc{
AppState: gnoland.GnoGenesisState{Txs: []std.Tx{{}}},
AppState: gnoland.GnoGenesisState{Txs: []gnoland.TxWithMetadata{{}}},
}}, nil
},
getBlockResultsFn: func(uint64) (*core_types.ResultBlockResults, error) {
Expand Down Expand Up @@ -1365,6 +1365,23 @@ func generateTransactions(t *testing.T, count int) []*std.Tx {
return txs
}

// generateGenesisTransactions generates dummy genesis transactions
func generateGenesisTransactions(t *testing.T, count int) []*gnoland.TxWithMetadata {
t.Helper()

txs := make([]*gnoland.TxWithMetadata, count)

for i := 0; i < count; i++ {
txs[i] = &gnoland.TxWithMetadata{
Tx: std.Tx{
Memo: fmt.Sprintf("memo %d", i),
},
}
}

return txs
}

// generateBlocks generates dummy blocks
func generateBlocks(
t *testing.T,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/99designs/gqlgen v0.17.54
github.com/ajnavarro/gqlfiltergen v0.1.2
github.com/cockroachdb/pebble v1.1.2
github.com/gnolang/gno v0.2.1-0.20240927151923-69400d468d7b
github.com/gnolang/gno v0.0.0-20241106190630-81a88a2976ba
github.com/go-chi/chi/v5 v5.1.0
github.com/go-chi/httprate v0.14.1
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -85,6 +85,6 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/gnolang/gno v0.2.1-0.20240927151923-69400d468d7b h1:IAgATivc2zPHK8mggSVWraDzMcE7pOA/IC3ydmGCsds=
github.com/gnolang/gno v0.2.1-0.20240927151923-69400d468d7b/go.mod h1:JcSIol3+SAlhMKHQTjlyoi4CrQqDd/HrrMIsjQpOxxQ=
github.com/gnolang/gno v0.0.0-20241106190630-81a88a2976ba h1:88dSkWof2M9SOOqqCU5eY7bHC15BpjdYApzImhTtmWQ=
github.com/gnolang/gno v0.0.0-20241106190630-81a88a2976ba/go.mod h1:UlU+FYRfmTCIvmid4S7rUuWsjOuIPGSwjREof1T0WAs=
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 h1:GKvsK3oLWG9B1GL7WP/VqwM6C92j5tIvB844oggL9Lk=
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216/go.mod h1:xJhtEL7ahjM1WJipt89gel8tHzfIl/LyMY+lCYh38d8=
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
Expand Down Expand Up @@ -312,8 +312,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down

0 comments on commit 5701299

Please sign in to comment.