Skip to content

Commit

Permalink
wallet - test DLEQ proofs from nutshell mint
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Sep 19, 2024
1 parent ff99776 commit 55757ba
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions wallet/wallet_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

btcdocker "github.com/elnosh/btc-docker-test"
"github.com/elnosh/gonuts/cashu"
"github.com/elnosh/gonuts/cashu/nuts/nut12"
"github.com/elnosh/gonuts/testutils"
"github.com/elnosh/gonuts/wallet"
"github.com/lightningnetwork/lnd/lnrpc"
Expand Down Expand Up @@ -896,6 +897,62 @@ func TestSendToPubkeyNutshell(t *testing.T) {
testP2PK(t, testWallet, testWallet2, true)
}

func TestDLEQProofsNutshell(t *testing.T) {
nutshellMint, err := testutils.CreateNutshellMintContainer(ctx, 0)
if err != nil {
t.Fatalf("error starting nutshell mint: %v", err)
}
defer nutshellMint.Terminate(ctx)
nutshellURL := nutshellMint.Host

testWalletPath := filepath.Join(".", "/testwalletdleq")
testWallet, err := testutils.CreateTestWallet(testWalletPath, nutshellURL)
if err != nil {
t.Fatal(err)
}
defer func() {
os.RemoveAll(testWalletPath)
}()

keysets, err := wallet.GetMintActiveKeysets(nutshellURL)
if err != nil {
t.Fatalf("unexpected error getting keysets: %v", err)
}

mintRes, err := testWallet.RequestMint(10000)
if err != nil {
t.Fatalf("unexpected error requesting mint: %v", err)
}

proofs, err := testWallet.MintTokens(mintRes.Quote)
if err != nil {
t.Fatalf("unexpected error minting tokens: %v", err)
}

for _, proof := range proofs {
if proof.DLEQ == nil {
t.Fatal("got nil DLEQ proof from MintTokens")
}
}
if !nut12.VerifyProofsDLEQ(proofs, keysets) {
t.Fatal("invalid DLEQ proofs returned from MintTokens")
}

proofsToSend, err := testWallet.Send(2100, nutshellURL, false)
if err != nil {
t.Fatalf("unexpected error in Send: %v", err)
}
for _, proof := range proofsToSend {
if proof.DLEQ == nil {
t.Fatal("got nil DLEQ proof from Send")
}
}
if !nut12.VerifyProofsDLEQ(proofsToSend, keysets) {
t.Fatal("invalid DLEQ proofs returned from Send")
}

}

func TestWalletRestoreNutshell(t *testing.T) {
nutshellMint, err := testutils.CreateNutshellMintContainer(ctx, 0)
if err != nil {
Expand Down

0 comments on commit 55757ba

Please sign in to comment.