forked from cerc-io/laconicd-deprecated
07435d0597
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package backend
|
|||
|
|||
import (
|
|||
"fmt"
|
|||
|
|||
"github.com/tendermint/tendermint/proto/tendermint/crypto"
|
|||
)
|
|||
|
|||
func mookProofs(num int, withData bool) *crypto.ProofOps {
|
|||
var proofOps *crypto.ProofOps
|
|||
if num > 0 {
|
|||
proofOps = new(crypto.ProofOps)
|
|||
for i := 0; i < num; i++ {
|
|||
proof := crypto.ProofOp{}
|
|||
if withData {
|
|||
proof.Data = []byte("\n\031\n\003KEY\022\005VALUE\032\013\010\001\030\001 \001*\003\000\002\002")
|
|||
}
|
|||
proofOps.Ops = append(proofOps.Ops, proof)
|
|||
}
|
|||
}
|
|||
return proofOps
|
|||
}
|
|||
|
|||
func (suite *BackendTestSuite) TestGetHexProofs() {
|
|||
defaultRes := []string{""}
|
|||
testCases := []struct {
|
|||
name string
|
|||
proof *crypto.ProofOps
|
|||
exp []string
|
|||
}{
|
|||
{
|
|||
"no proof provided",
|
|||
mookProofs(0, false),
|
|||
defaultRes,
|
|||
},
|
|||
{
|
|||
"no proof data provided",
|
|||
mookProofs(1, false),
|
|||
defaultRes,
|
|||
},
|
|||
{
|
|||
"valid proof provided",
|
|||
mookProofs(1, true),
|
|||
[]string{"0x0a190a034b4559120556414c55451a0b0801180120012a03000202"},
|
|||
},
|
|||
}
|
|||
for _, tc := range testCases {
|
|||
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
|||
suite.Require().Equal(tc.exp, GetHexProofs(tc.proof))
|
|||
})
|
|||
}
|
|||
}
|