forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from maticnetwork/mardizzone/revert
Revert "chg: bump deps and skip some tests due to tendermint upgrade"
- Loading branch information
Showing
13 changed files
with
302 additions
and
3,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,118 @@ | ||
// Code generated by MockGen. DO NOT EDIT. | ||
// Source: crypto/ledger_secp256k1.go | ||
//go:build ledger && test_ledger_mock | ||
// +build ledger,test_ledger_mock | ||
|
||
// Package crypto is a generated GoMock package. | ||
package crypto | ||
|
||
import ( | ||
reflect "reflect" | ||
"fmt" | ||
|
||
gomock "github.com/golang/mock/gomock" | ||
"github.com/btcsuite/btcd/btcec/v2" | ||
"github.com/pkg/errors" | ||
|
||
secp256k1 "github.com/tendermint/btcd/btcec" | ||
"github.com/tendermint/tendermint/crypto" | ||
tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1" | ||
|
||
bip39 "github.com/cosmos/go-bip39" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/keys/hd" | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// MockLedgerSECP256K1 is a mock of LedgerSECP256K1 interface. | ||
type MockLedgerSECP256K1 struct { | ||
ctrl *gomock.Controller | ||
recorder *MockLedgerSECP256K1MockRecorder | ||
// If ledger support (build tag) has been enabled, which implies a CGO dependency, | ||
// set the discoverLedger function which is responsible for loading the Ledger | ||
// device at runtime or returning an error. | ||
func init() { | ||
discoverLedger = func() (LedgerSECP256K1, error) { | ||
return LedgerSECP256K1Mock{}, nil | ||
} | ||
} | ||
|
||
// MockLedgerSECP256K1MockRecorder is the mock recorder for MockLedgerSECP256K1. | ||
type MockLedgerSECP256K1MockRecorder struct { | ||
mock *MockLedgerSECP256K1 | ||
type LedgerSECP256K1Mock struct { | ||
} | ||
|
||
// NewMockLedgerSECP256K1 creates a new mock instance. | ||
func NewMockLedgerSECP256K1(ctrl *gomock.Controller) *MockLedgerSECP256K1 { | ||
mock := &MockLedgerSECP256K1{ctrl: ctrl} | ||
mock.recorder = &MockLedgerSECP256K1MockRecorder{mock} | ||
return mock | ||
func (mock LedgerSECP256K1Mock) Close() error { | ||
return nil | ||
} | ||
|
||
// EXPECT returns an object that allows the caller to indicate expected use. | ||
func (m *MockLedgerSECP256K1) EXPECT() *MockLedgerSECP256K1MockRecorder { | ||
return m.recorder | ||
} | ||
// GetPublicKeySECP256K1 mocks a ledger device | ||
// as per the original API, it returns an uncompressed key | ||
func (mock LedgerSECP256K1Mock) GetPublicKeySECP256K1(derivationPath []uint32) ([]byte, error) { | ||
if derivationPath[0] != 44 { | ||
return nil, errors.New("Invalid derivation path") | ||
} | ||
|
||
// Close mocks base method. | ||
func (m *MockLedgerSECP256K1) Close() error { | ||
m.ctrl.T.Helper() | ||
ret := m.ctrl.Call(m, "Close") | ||
ret0, _ := ret[0].(error) | ||
return ret0 | ||
} | ||
if derivationPath[1] != sdk.GetConfig().GetCoinType() { | ||
return nil, errors.New("Invalid derivation path") | ||
} | ||
|
||
// Close indicates an expected call of Close. | ||
func (mr *MockLedgerSECP256K1MockRecorder) Close() *gomock.Call { | ||
mr.mock.ctrl.T.Helper() | ||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockLedgerSECP256K1)(nil).Close)) | ||
} | ||
seed, err := bip39.NewSeedWithErrorChecking(tests.TestMnemonic, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// GetAddressPubKeySECP256K1 mocks base method. | ||
func (m *MockLedgerSECP256K1) GetAddressPubKeySECP256K1(arg0 []uint32, arg1 string) ([]byte, string, error) { | ||
m.ctrl.T.Helper() | ||
ret := m.ctrl.Call(m, "GetAddressPubKeySECP256K1", arg0, arg1) | ||
ret0, _ := ret[0].([]byte) | ||
ret1, _ := ret[1].(string) | ||
ret2, _ := ret[2].(error) | ||
return ret0, ret1, ret2 | ||
} | ||
path := hd.NewParams(derivationPath[0], derivationPath[1], derivationPath[2], derivationPath[3] != 0, derivationPath[4]) | ||
masterPriv, ch := hd.ComputeMastersFromSeed(seed) | ||
derivedPriv, err := hd.DerivePrivateKeyForPath(masterPriv, ch, path.String()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// GetAddressPubKeySECP256K1 indicates an expected call of GetAddressPubKeySECP256K1. | ||
func (mr *MockLedgerSECP256K1MockRecorder) GetAddressPubKeySECP256K1(arg0, arg1 interface{}) *gomock.Call { | ||
mr.mock.ctrl.T.Helper() | ||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAddressPubKeySECP256K1", reflect.TypeOf((*MockLedgerSECP256K1)(nil).GetAddressPubKeySECP256K1), arg0, arg1) | ||
} | ||
_, pubkeyObject := secp256k1.PrivKeyFromBytes(secp256k1.S256(), derivedPriv[:]) | ||
|
||
// GetPublicKeySECP256K1 mocks base method. | ||
func (m *MockLedgerSECP256K1) GetPublicKeySECP256K1(arg0 []uint32) ([]byte, error) { | ||
m.ctrl.T.Helper() | ||
ret := m.ctrl.Call(m, "GetPublicKeySECP256K1", arg0) | ||
ret0, _ := ret[0].([]byte) | ||
ret1, _ := ret[1].(error) | ||
return ret0, ret1 | ||
return pubkeyObject.SerializeUncompressed(), nil | ||
} | ||
|
||
// GetPublicKeySECP256K1 indicates an expected call of GetPublicKeySECP256K1. | ||
func (mr *MockLedgerSECP256K1MockRecorder) GetPublicKeySECP256K1(arg0 interface{}) *gomock.Call { | ||
mr.mock.ctrl.T.Helper() | ||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublicKeySECP256K1", reflect.TypeOf((*MockLedgerSECP256K1)(nil).GetPublicKeySECP256K1), arg0) | ||
// GetAddressPubKeySECP256K1 mocks a ledger device | ||
// as per the original API, it returns a compressed key and a bech32 address | ||
func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint32, hrp string) ([]byte, string, error) { | ||
pk, err := mock.GetPublicKeySECP256K1(derivationPath) | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
// re-serialize in the 33-byte compressed format | ||
cmp, err := btcec.ParsePubKey(pk[:], btcec.S256()) | ||
if err != nil { | ||
return nil, "", fmt.Errorf("error parsing public key: %v", err) | ||
} | ||
|
||
var compressedPublicKey tmsecp256k1.PubKeySecp256k1 | ||
copy(compressedPublicKey[:], cmp.SerializeCompressed()) | ||
|
||
// Generate the bech32 addr using existing tmcrypto/etc. | ||
addr := sdk.AccAddress(compressedPublicKey.Address()).String() | ||
return pk, addr, err | ||
} | ||
|
||
// SignSECP256K1 mocks base method. | ||
func (m *MockLedgerSECP256K1) SignSECP256K1(arg0 []uint32, arg1 []byte) ([]byte, error) { | ||
m.ctrl.T.Helper() | ||
ret := m.ctrl.Call(m, "SignSECP256K1", arg0, arg1) | ||
ret0, _ := ret[0].([]byte) | ||
ret1, _ := ret[1].(error) | ||
return ret0, ret1 | ||
func (mock LedgerSECP256K1Mock) SignSECP256K1(derivationPath []uint32, message []byte) ([]byte, error) { | ||
path := hd.NewParams(derivationPath[0], derivationPath[1], derivationPath[2], derivationPath[3] != 0, derivationPath[4]) | ||
seed, err := bip39.NewSeedWithErrorChecking(tests.TestMnemonic, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
masterPriv, ch := hd.ComputeMastersFromSeed(seed) | ||
derivedPriv, err := hd.DerivePrivateKeyForPath(masterPriv, ch, path.String()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), derivedPriv[:]) | ||
|
||
sig, err := priv.Sign(crypto.Sha256(message)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Need to return DER as the ledger does | ||
sig2 := btcec.Signature{R: sig.R, S: sig.S} | ||
return sig2.Serialize(), nil | ||
} | ||
|
||
// SignSECP256K1 indicates an expected call of SignSECP256K1. | ||
func (mr *MockLedgerSECP256K1MockRecorder) SignSECP256K1(arg0, arg1 interface{}) *gomock.Call { | ||
mr.mock.ctrl.T.Helper() | ||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignSECP256K1", reflect.TypeOf((*MockLedgerSECP256K1)(nil).SignSECP256K1), arg0, arg1) | ||
// ShowAddressSECP256K1 shows the address for the corresponding bip32 derivation path | ||
func (mock LedgerSECP256K1Mock) ShowAddressSECP256K1(bip32Path []uint32, hrp string) error { | ||
fmt.Printf("Request to show address for %v at %v", hrp, bip32Path) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.