lnd/keychain/bench_test.go
Oliver Gugger 7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00

42 lines
688 B
Go

package keychain
import (
"testing"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require"
)
func BenchmarkDerivePrivKey(t *testing.B) {
cleanUp, wallet, err := createTestBtcWallet(
CoinTypeBitcoin,
)
if err != nil {
t.Fatalf("unable to create wallet: %v", err)
}
keyRing := NewBtcWalletKeyRing(wallet, CoinTypeBitcoin)
defer cleanUp()
var (
privKey *btcec.PrivateKey
)
keyDesc := KeyDescriptor{
KeyLocator: KeyLocator{
Family: KeyFamilyMultiSig,
Index: 1,
},
}
t.ReportAllocs()
t.ResetTimer()
for i := 0; i < t.N; i++ {
privKey, err = keyRing.DerivePrivKey(keyDesc)
}
require.NoError(t, err)
require.NotNil(t, privKey)
}