Skip to content

Commit

Permalink
fix all but one test
Browse files Browse the repository at this point in the history
  • Loading branch information
husio committed Apr 8, 2019
1 parent a5ea25f commit 40f4e60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
9 changes: 4 additions & 5 deletions cmd/bnsd/app/testdata/fixtures/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func appStateGenesis(keyAddress weave.Address) []byte {
},
},
},
"cashconf": cash.Configuration{
CollectorAddress: weave.Condition("dist/revenue/0000000000000001").Address(),
MinimalFee: coin.NewCoin(0, 10000000, "FRNK"),
},
"currencies": []interface{}{
dict{
"ticker": "FRNK",
Expand Down Expand Up @@ -117,10 +121,6 @@ func appStateGenesis(keyAddress weave.Address) []byte {
"timeout": time.Now().Add(10000 * time.Hour),
},
},
"cashconf": cash.Configuration{
CollectorAddress: weave.Condition("dist/revenue/0000000000000001").Address(),
MinimalFee: coin.NewCoin(0, 10000000, "FRNK"),
},
"msgfee": []interface{}{
dict{
"msg_path": "distribution/newrevenue",
Expand All @@ -143,6 +143,5 @@ func appStateGenesis(keyAddress weave.Address) []byte {
if err != nil {
panic(err)
}
fmt.Println(string(appState))
return appState
}
16 changes: 13 additions & 3 deletions examples/mycoind/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"bytes"
"encoding/hex"
"encoding/json"
"testing"

Expand Down Expand Up @@ -38,9 +39,9 @@ func testInitChain(t *testing.T, myApp app.BaseApp, addr string) {
},
},
},
"gconf": dict{
cash.GconfCollectorAddress: "66616b652d636f6c6c6563746f722d61646472657373",
cash.GconfMinimalFee: coin.Coin{Whole: 0}, // no fee
"cashconf": cash.Configuration{
CollectorAddress: fromHex(t, "3b11c732b8fc1f09beb34031302fe2ab347c5c14"),
MinimalFee: coin.Coin{Whole: 0}, // no fee
},
})
if err != nil {
Expand All @@ -55,6 +56,15 @@ func testInitChain(t *testing.T, myApp app.BaseApp, addr string) {

}

func fromHex(t testing.TB, s string) weave.Address {
t.Helper()
raw, err := hex.DecodeString(s)
if err != nil {
t.Fatalf("cannot decode hex encoded address %q: %s", s, err)
}
return raw
}

// testCommit will commit at height h and return new hash
func testCommit(t *testing.T, myApp app.BaseApp, h int64) []byte {
// Commit first block, make sure non-nil hash
Expand Down
14 changes: 9 additions & 5 deletions examples/mycoind/app/init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/hex"
"encoding/json"
"fmt"
"path/filepath"
Expand All @@ -10,7 +11,7 @@ import (
"github.com/iov-one/weave/coin"
"github.com/iov-one/weave/commands/server"
"github.com/iov-one/weave/crypto"
"github.com/iov-one/weave/gconf"
"github.com/iov-one/weave/errors"
"github.com/iov-one/weave/x/cash"
abci "github.com/tendermint/tendermint/abci/types"
)
Expand Down Expand Up @@ -43,6 +44,10 @@ func GenInitOptions(args []string) (json.RawMessage, error) {
dict map[string]interface{}
array []interface{}
)
collectorAddr, err := hex.DecodeString("3b11c732b8fc1f09beb34031302fe2ab347c5c14")
if err != nil {
return nil, errors.Wrap(err, "cannot hex decode collector address")
}
return json.Marshal(dict{
"cash": array{
dict{
Expand All @@ -55,9 +60,9 @@ func GenInitOptions(args []string) (json.RawMessage, error) {
},
},
},
"gconf": dict{
cash.GconfCollectorAddress: "66616b652d636f6c6c6563746f722d61646472657373",
cash.GconfMinimalFee: coin.Coin{Whole: 0}, // no fee
"cashconf": cash.Configuration{
CollectorAddress: collectorAddr,
MinimalFee: coin.Coin{Whole: 0}, // no fee
},
})
}
Expand All @@ -76,7 +81,6 @@ func GenerateApp(options *server.Options) (abci.Application, error) {
return nil, err
}
application.WithInit(app.ChainInitializers(
&gconf.Initializer{},
&cash.Initializer{},
))

Expand Down

0 comments on commit 40f4e60

Please sign in to comment.