cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.24k stars 3.61k forks source link

test in tests/tendermint/main.go fails #2

Closed davehaughton1 closed 7 years ago

davehaughton1 commented 8 years ago

Hi, running tests/tendermint/main.go does not work correctly.

On line 116 in github.com/tendermint/basecoin/app/app.go you have: res = sm.ExecTx(app.cacheState, app.plugins, tx, true, nil)

The function is given the argument app.cacheState, but I dont think that cacheState is ever initialized. Perhaps it should just be app.state?

ethanfrey commented 7 years ago

Hmmm.... just checked this on the master/develop branch, running make test

1) go test github.com/tendermint/basecoin/... passes with no problems

2) go run tests/tmsp/*.go failes even after make update_deps...

testGov:

Basecoin v0.1
SET 676F762F652FDD8C9EFA93F268CEB8D8336F9B05C4074C9F6D71 0114DD8C9EFA93F268CEB8D8336F9B05C4074C9F6D7101DE7F5EC1C84E76A930B476DF44F310C585274A17AF4371A23FC9CF3CE9B618F7
SET 676F762F672F61646D696E 010561646D696E000001010114DD8C9EFA93F268CEB8D8336F9B05C4074C9F6D710000000000000001
SET 626173652F612FDD8C9EFA93F268CEB8D8336F9B05C4074C9F6D71 0101DE7F5EC1C84E76A930B476DF44F310C585274A17AF4371A23FC9CF3CE9B618F7000101000020000000000000
>> B
SET 676F762F652F4D9E98B6D5853BFE840403BC4BD4C8733A14F364 01144D9E98B6D5853BFE840403BC4BD4C8733A14F36401293795AE33FB34922E7EF80C26C411C598DF1720FE13175AE8EEF1FA8C48BE60
SET 676F762F652F5245D647B58C5BB4829DBBF402F275FCF15C5EB9 01145245D647B58C5BB4829DBBF402F275FCF15C5EB901A9029ED540E459A0E71C43141225302A58EFD26C404D1805C72B62044AE79662
SET 676F762F652F4F62971EBD50F60CB2585294E75F9A620534D7AB 01144F62971EBD50F60CB2585294E75F9A620534D7AB01CDFD20FF8A82C2603A0C3358A78A6F8573D4606F2A4F0BC051953B0E67F438CA
>> &{validators  0 [{[77 158 152 182 213 133 59 254 132 4 3 188 75 212 200 115 58 20 243 100] 1} {[82 69 214 71 181 140 91 180 130 157 187 244 2 242 117 252 241 92 94 185] 1} {[79 98 151 30 189 80 246 12 178 88 82 148 231 95 154 98 5 52 215 171] 1}]}
SET 676F762F672F76616C696461746F7273 010A76616C696461746F72730000010301144D9E98B6D5853BFE840403BC4BD4C8733A14F364000000000000000101145245D647B58C5BB4829DBBF402F275FCF15C5EB9000000000000000101144F62971EBD50F60CB2585294E75F9A620534D7AB0000000000000001
Failed to query validators: TMSP code:BaseUnknownPlugin, data:, log:Unknown plugin with type byte 58
exit status 1

and testSequence:

Basecoin v0.1
SET 626173652F612F12BB36B57DA6E4EC8229F4D99E14567F1E528B0F 0101F33235D17F08FE3301747E873D83CDF37C317CB448E4B65D3FDD00C08D57A24E000101000020000000000000
Success
SET 626173652F612F12BB36B57DA6E4EC8229F4D99E14567F1E528B0F 0101F33235D17F08FE3301747E873D83CDF37C317CB448E4B65D3FDD00C08D57A24E0101010100001FFFFFFFF0BDBE
SET 626173652F612F8CCEA7851B70AD986CACC47271C76A8A743B2D4D 01000001010000000000000F4240
AppendTx error: TMSP code:BaseInvalidInput, data:, log:Error in AppendTx;in validateInputsBasic();Error (base) invalid input;PubKey must be nil when Sequence > 1
exit status 1

I have the current master branch checked out for governmint.

ethanfrey commented 7 years ago

This code in the test seems to be invalid:

    // Query for validator set
    res := bcApp.Query([]byte("XXX"))
    if res.IsErr() {
        Exit(Fmt("Failed to query validators: %v", res.Error()))
    }

It is handled here (in basecoin/app/app.go):

// TMSP::Query
func (app *Basecoin) Query(query []byte) (res tmsp.Result) {
    if len(query) == 0 {
        return tmsp.ErrEncodingError.SetLog("Query cannot be zero length")
    }
    typeByte := query[0]
    query = query[1:]
    switch typeByte {
    case PluginTypeByteBase:
        return tmsp.OK.SetLog("This type of query not yet supported")
    case PluginTypeByteEyes:
        return app.eyesCli.QuerySync(query)
    }
    return tmsp.ErrBaseUnknownPlugin.SetLog(
        Fmt("Unknown plugin with type byte %X", typeByte))
}

It seems like this could never pass, as the type byte must be 0x01 or 0x02... not X.

Not sure if this code even matters to be fixed, or just removed?

rigelrozanski commented 7 years ago

@ethanfrey go run tests/tmsp/*.go have been fixed in latest commits. Code should be modified to utilize the go testing toolkit, but works as a part of the current make test command

ethanfrey commented 7 years ago

Alright, then this issue is closed. Thanks rigel!