From b189018090d445b02c0b75fe28e721e56af3bb05 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sun, 12 Feb 2017 19:01:17 -0800 Subject: [PATCH] s/adam/basecoin/g; fix tests --- cmd/adam/main.go | 30 ------------------------- demo/clean.sh | 2 +- demo/start.sh | 18 +++++++-------- docs/guide/ibc.md | 21 +++++++++-------- docs/guide/src/example-plugin/plugin.go | 6 ++--- plugins/counter/counter.go | 9 +++----- plugins/counter/counter_test.go | 5 ++--- 7 files changed, 28 insertions(+), 63 deletions(-) delete mode 100644 cmd/adam/main.go diff --git a/cmd/adam/main.go b/cmd/adam/main.go deleted file mode 100644 index 9be7255e7c..0000000000 --- a/cmd/adam/main.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "os" - - "github.com/tendermint/basecoin/cmd/commands" - - "github.com/urfave/cli" -) - -func init() { - commands.RegisterIBC() -} - -func main() { - app := cli.NewApp() - app.Name = "adam" - app.Usage = "adam [command] [args...]" - app.Version = "0.1.0" - app.Commands = []cli.Command{ - commands.StartCmd, - commands.TxCmd, - commands.KeyCmd, - commands.QueryCmd, - commands.VerifyCmd, // TODO: move to merkleeyes? - commands.BlockCmd, - commands.AccountCmd, - } - app.Run(os.Args) -} diff --git a/demo/clean.sh b/demo/clean.sh index 7d18923212..e2d519337d 100644 --- a/demo/clean.sh +++ b/demo/clean.sh @@ -1,6 +1,6 @@ #! /bin/bash -killall -9 adam tendermint +killall -9 basecoin tendermint TMROOT=./data/chain1/tendermint tendermint unsafe_reset_all TMROOT=./data/chain2/tendermint tendermint unsafe_reset_all diff --git a/demo/start.sh b/demo/start.sh index b856852dea..ad5da68d1c 100644 --- a/demo/start.sh +++ b/demo/start.sh @@ -26,11 +26,11 @@ echo "... starting chains" echo "" # start the first node TMROOT=./data/chain1/tendermint tendermint node &> chain1_tendermint.log & -adam start --dir ./data/chain1/basecoin &> chain1_basecoin.log & +basecoin start --dir ./data/chain1/basecoin &> chain1_basecoin.log & # start the second node TMROOT=./data/chain2/tendermint tendermint node --node_laddr tcp://localhost:36656 --rpc_laddr tcp://localhost:36657 --proxy_app tcp://localhost:36658 &> chain2_tendermint.log & -adam start --address tcp://localhost:36658 --dir ./data/chain2/basecoin &> chain2_basecoin.log & +basecoin start --address tcp://localhost:36658 --dir ./data/chain2/basecoin &> chain2_basecoin.log & echo "" echo "... waiting for chains to start" @@ -40,20 +40,20 @@ sleep 10 echo "... registering chain1 on chain2" echo "" # register chain1 on chain2 -adam tx ibc --amount 10 $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json echo "" echo "... creating egress packet on chain1" echo "" # create a packet on chain1 destined for chain2 PAYLOAD="DEADBEEF" #TODO -adam tx ibc --amount 10 $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload $PAYLOAD --sequence 1 +basecoin tx ibc --amount 10 $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload $PAYLOAD --sequence 1 echo "" echo "... querying for packet data" echo "" # query for the packet data and proof -QUERY_RESULT=$(adam query ibc,egress,$CHAIN_ID1,$CHAIN_ID2,1) +QUERY_RESULT=$(basecoin query ibc,egress,$CHAIN_ID1,$CHAIN_ID2,1) HEIGHT=$(echo $QUERY_RESULT | jq .height) PACKET=$(echo $QUERY_RESULT | jq .value) PROOF=$(echo $QUERY_RESULT | jq .proof) @@ -75,7 +75,7 @@ echo "" echo "... querying for block data" echo "" # get the header and commit for the height -HEADER_AND_COMMIT=$(adam block $HEIGHT) +HEADER_AND_COMMIT=$(basecoin block $HEIGHT) HEADER=$(echo $HEADER_AND_COMMIT | jq .hex.header) HEADER=$(removeQuotes $HEADER) COMMIT=$(echo $HEADER_AND_COMMIT | jq .hex.commit) @@ -89,19 +89,19 @@ echo "" echo "... updating state of chain1 on chain2" echo "" # update the state of chain1 on chain2 -adam tx ibc --amount 10 $CHAIN_FLAGS2 update --header 0x$HEADER --commit 0x$COMMIT +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 update --header 0x$HEADER --commit 0x$COMMIT echo "" echo "... posting packet from chain1 on chain2" echo "" # post the packet from chain1 to chain2 -adam tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height $((HEIGHT + 1)) --packet 0x$PACKET --proof 0x$PROOF +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height $((HEIGHT + 1)) --packet 0x$PACKET --proof 0x$PROOF echo "" echo "... checking if the packet is present on chain2" echo "" # query for the packet on chain2 ! -adam query --node tcp://localhost:36657 ibc,ingress,test_chain_2,test_chain_1,1 +basecoin query --node tcp://localhost:36657 ibc,ingress,test_chain_2,test_chain_1,1 echo "" echo "DONE!" diff --git a/docs/guide/ibc.md b/docs/guide/ibc.md index 66f874d3a0..4bd3228140 100644 --- a/docs/guide/ibc.md +++ b/docs/guide/ibc.md @@ -181,10 +181,9 @@ Now that we have all the background knowledge, let's actually walk through the t Make sure you have installed [tendermint](https://tendermint.com/intro/getting-started/download) and -[adam](/docs/guide/install.md). +[basecoin](/docs/guide/install.md). -`adam` is the name for the program that will become the Cosmos Hub. -We call it Adam because it's the first blockchain in [the Cosmos Network](https://cosmos.network). +`basecoin` is a framework for creating new cryptocurrency applications. Now let's start the two blockchains. In this tutorial, each chain will have only a single validator, @@ -201,14 +200,14 @@ We can start the two chains as follows: ``` TMROOT=./data/chain1/tendermint tendermint node &> chain1_tendermint.log & -adam start --dir ./data/chain1/basecoin &> chain1_adam.log & +basecoin start --dir ./data/chain1/basecoin &> chain1_basecoin.log & ``` and ``` TMROOT=./data/chain2/tendermint tendermint node --node_laddr tcp://localhost:36656 --rpc_laddr tcp://localhost:36657 --proxy_app tcp://localhost:36658 &> chain2_tendermint.log & -adam start --address tcp://localhost:36658 --dir ./data/chain2/basecoin &> chain2_basecoin.log & +basecoin start --address tcp://localhost:36658 --dir ./data/chain2/basecoin &> chain2_basecoin.log & ``` Note how we refer to the relevant data directories. Also note how we have to set the various addresses for the second node so as not to conflict with the first. @@ -237,20 +236,20 @@ export CHAIN_FLAGS2="--chain_id $CHAIN_ID2 --from ./data/chain2/basecoin/key.jso Let's start by registering `test_chain_1` on `test_chain_2`: ``` -adam tx ibc --amount 10 $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json ``` Now we can create the outgoing packet on `test_chain_1`: ``` -adam tx ibc --amount 10 $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1 +basecoin tx ibc --amount 10 $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1 ``` Note our payload is just `DEADBEEF`. Now that the packet is committed in the chain, let's get some proof by querying: ``` -adam query ibc,egress,$CHAIN_ID1,$CHAIN_ID2,1 +basecoin query ibc,egress,$CHAIN_ID1,$CHAIN_ID2,1 ``` The result contains the latest height, a value (ie. the hex-encoded binary serialization of our packet), @@ -261,7 +260,7 @@ We'll need a recent block header and a set of commit signatures. Fortunately, we can get them with the `block` command: ``` -adam block +basecoin block ``` where `` is the height returned in the previous query. @@ -271,7 +270,7 @@ The former is used as input for later commands; the latter is human-readable, so Let's send this updated information about `test_chain_1` to `test_chain_2`: ``` -adam tx ibc --amount 10 $CHAIN_FLAGS2 update --header 0x
--commit 0x +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 update --header 0x
--commit 0x ``` where `
` and `` are the hex-encoded header and commit returned by the previous `block` command. @@ -281,7 +280,7 @@ along with proof the packet was committed on `test_chain_1`. Since `test_chain_2 of `test_chain_1`, it will be able to verify the proof! ``` -adam tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height --packet 0x --proof 0x +basecoin tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height --packet 0x --proof 0x ``` Here, `` is one greater than the height retuned by the previous `query` command, and `` and `` are the diff --git a/docs/guide/src/example-plugin/plugin.go b/docs/guide/src/example-plugin/plugin.go index 81bb365e50..e930ffbf90 100644 --- a/docs/guide/src/example-plugin/plugin.go +++ b/docs/guide/src/example-plugin/plugin.go @@ -72,9 +72,9 @@ func (ep *ExamplePlugin) RunTx(store types.KVStore, ctx types.CallContext, txByt func (ep *ExamplePlugin) InitChain(store types.KVStore, vals []*abci.Validator) { } -func (ep *ExamplePlugin) BeginBlock(store types.KVStore, height uint64) { +func (ep *ExamplePlugin) BeginBlock(store types.KVStore, hash []byte, header *abci.Header) { } -func (ep *ExamplePlugin) EndBlock(store types.KVStore, height uint64) []*abci.Validator { - return nil +func (ep *ExamplePlugin) EndBlock(store types.KVStore, height uint64) abci.ResponseEndBlock { + return abci.ResponseEndBlock{} } diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index be9ec4041f..9d849d1d05 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -21,21 +21,18 @@ type CounterTx struct { //-------------------------------------------------------------------------------- type CounterPlugin struct { - name string } func (cp *CounterPlugin) Name() string { - return cp.name + return "counter" } func (cp *CounterPlugin) StateKey() []byte { - return []byte(fmt.Sprintf("CounterPlugin{name=%v}.State", cp.name)) + return []byte(fmt.Sprintf("CounterPlugin.State")) } func New() *CounterPlugin { - return &CounterPlugin{ - name: "counter", - } + return &CounterPlugin{} } func (cp *CounterPlugin) SetOption(store types.KVStore, key string, value string) (log string) { diff --git a/plugins/counter/counter_test.go b/plugins/counter/counter_test.go index 6cc99bd3a3..0b8ee4a866 100644 --- a/plugins/counter/counter_test.go +++ b/plugins/counter/counter_test.go @@ -22,8 +22,7 @@ func TestCounterPlugin(t *testing.T) { t.Log(bcApp.Info()) // Add Counter plugin - counterPluginName := "testcounter" - counterPlugin := New(counterPluginName) + counterPlugin := New() bcApp.RegisterPlugin(counterPlugin) // Account initialization @@ -40,7 +39,7 @@ func TestCounterPlugin(t *testing.T) { tx := &types.AppTx{ Gas: gas, Fee: fee, - Name: counterPluginName, + Name: "counter", Input: types.NewTxInput(test1Acc.PubKey, inputCoins, inputSequence), Data: wire.BinaryBytes(CounterTx{Valid: true, Fee: appFee}), }