Test query ibc status and fix bugs

This commit is contained in:
Ethan Frey
2017-07-27 16:30:20 -04:00
parent fd10387eb5
commit aad5a0f3a0
4 changed files with 53 additions and 5 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ func ibcQueryCmd(cmd *cobra.Command, args []string) error {
func chainsQueryCmd(cmd *cobra.Command, args []string) error {
list := [][]byte{}
key := stack.PrefixedKey(ibc.NameIBC, ibc.HandlerKey())
key := stack.PrefixedKey(ibc.NameIBC, ibc.ChainsKey())
proof, err := proofcmd.GetAndParseAppProof(key, &list)
if err != nil {
return err
+9 -2
View File
@@ -145,7 +145,8 @@ func (h Handler) updateSeed(ctx basecoin.Context, store state.KVStore,
t UpdateChainTx) (res basecoin.Result, err error) {
chainID := t.ChainID()
if !NewChainSet(store).Exists([]byte(chainID)) {
s := NewChainSet(store)
if !s.Exists([]byte(chainID)) {
return res, ErrNotRegistered(chainID)
}
@@ -159,7 +160,13 @@ func (h Handler) updateSeed(ctx basecoin.Context, store state.KVStore,
// this will import the seed if it is valid in the current context
err = cert.Update(seed.Checkpoint, seed.Validators)
return res, ErrInvalidCommit(err)
if err != nil {
return res, ErrInvalidCommit(err)
}
// update the tracked height in chain info
err = s.Update(chainID, t.Seed.Height())
return res, err
}
// createPacket makes sure all permissions are good and the destination
+21
View File
@@ -62,6 +62,27 @@ func (c ChainSet) Register(chainID string, ourHeight uint64, theirHeight int) er
return nil
}
// Update sets the new tracked height on this chain
// returns error if not present
func (c ChainSet) Update(chainID string, theirHeight int) error {
d := c.Set.Get([]byte(chainID))
if len(d) == 0 {
return ErrNotRegistered(chainID)
}
// load the data
var info ChainInfo
err := wire.ReadBinaryBytes(d, &info)
if err != nil {
return err
}
// change the remote block and save it
info.RemoteBlock = theirHeight
d = wire.BinaryBytes(info)
c.Set.Set([]byte(chainID), d)
return nil
}
// Packet is a wrapped transaction and permission that we want to
// send off to another chain.
type Packet struct {