github.com/okex/exchain@v1.8.0/libs/ibc-go/testing/mock/privval_test.go (about)

     1  package mock_test
     2  
     3  // import (
     4  // 	"testing"
     5  
     6  // 	"github.com/stretchr/testify/require"
     7  // 	tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
     8  // 	tmtypes "github.com/tendermint/tendermint/types"
     9  
    10  // 	"github.com/okex/exchain/libs/ibc-go/testing/mock"
    11  // )
    12  
    13  const chainID = "testChain"
    14  
    15  // func TestGetPubKey(t *testing.T) {
    16  // 	pv := mock.NewPV()
    17  // 	pk, err := pv.GetPubKey()
    18  // 	require.NoError(t, err)
    19  // 	require.Equal(t, "ed25519", pk.Type())
    20  // }
    21  
    22  // func TestSignVote(t *testing.T) {
    23  // 	pv := mock.NewPV()
    24  // 	pk, _ := pv.GetPubKey()
    25  
    26  // 	vote := &tmproto.Vote{Height: 2}
    27  // 	pv.SignVote(chainID, vote)
    28  
    29  // 	msg := tmtypes.VoteSignBytes(chainID, vote)
    30  // 	ok := pk.VerifySignature(msg, vote.Signature)
    31  // 	require.True(t, ok)
    32  // }
    33  
    34  // func TestSignProposal(t *testing.T) {
    35  // 	pv := mock.NewPV()
    36  // 	pk, _ := pv.GetPubKey()
    37  
    38  // 	proposal := &tmproto.Proposal{Round: 2}
    39  // 	pv.SignProposal(chainID, proposal)
    40  
    41  // 	msg := tmtypes.ProposalSignBytes(chainID, proposal)
    42  // 	ok := pk.VerifySignature(msg, proposal.Signature)
    43  // 	require.True(t, ok)
    44  // }