Skip to content

Commit

Permalink
test: add memonic test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhangguiguang committed Apr 15, 2024
1 parent 0790d6c commit 3a37761
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions core/btc/account_derivation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,76 @@ func TestDerivation(t *testing.T) {
})
}
}

func TestUnisatCase(t *testing.T) {
mn := "certain tonight subway hazard parade security manual define maple magnet fix erosion"
type args struct {
mnemonic string
network string
addrType AddressType
}
tests := []struct {
name string
args args
wantAddr string
wantErr bool
}{
{
name: "testnet P2WPKH",
args: args{
mnemonic: mn,
network: ChainTestnet,
addrType: AddressTypeNativeSegwit,
},
wantAddr: "tb1qkevvrpwpydhk023l4eq0tlx4n9xam88j7cl8td",
},
{
name: "testnet P2SH-P2WPKH",
args: args{
mnemonic: mn,
network: ChainTestnet,
addrType: AddressTypeNestedSegwit,
},
wantAddr: "2MufMqgUTkHVUXnsRoYbQFbE5a7zMhpTHkU",
},
{
name: "testnet P2TR",
args: args{
mnemonic: mn,
network: ChainTestnet,
addrType: AddressTypeTaproot,
},
wantAddr: "tb1p5w4203pxzyz92glhj53lmwgvgcmmxx80khc9pgctpukx3pyrytaqt2saex",
},
{
name: "testnet P2PKH",
args: args{
mnemonic: mn,
network: ChainTestnet,
addrType: AddressTypeLegacy,
},
wantAddr: "mki7vqGxPmZcu1Uq3xyKmeoWetpCL9epGP",
},
{
name: "testnet Coming Taproot",
args: args{
mnemonic: mn,
network: ChainTestnet,
addrType: AddressTypeComingTaproot,
},
wantAddr: "tb1pk6sdtvvhshml36sghlrw55ppvxtp72mrwmgnu8zyw6ha7vxxaufqljj6yk",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
acc, err := NewAccountWithMnemonic(tt.args.mnemonic, tt.args.network, tt.args.addrType)
if (err != nil) != tt.wantErr {
t.Errorf("NewAccountWithMnemonic() error = %v, wantErr %v", err, tt.wantErr)
return
}
if (err == nil) && acc.Address() != tt.wantAddr {
t.Errorf("NewAccountWithMnemonic() got = %v, want %v", acc.Address(), tt.wantAddr)
}
})
}
}

0 comments on commit 3a37761

Please sign in to comment.