Skip to content

Commit

Permalink
Add test for package "ln"
Browse files Browse the repository at this point in the history
- Only one test for a helper function
- Tests for the actual LN client implementations not implemented yet

For #10
  • Loading branch information
philippgille committed Sep 8, 2018
1 parent 44a9040 commit a290870
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ln/ln_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ln_test

import (
"testing"

"github.com/philippgille/ln-paywall/ln"
)

// TestHashPreimage tests if the result of the HashPreimage function is correct.
func TestHashPreimage(t *testing.T) {
// Correct preimage form, taken from an invoice JSON in lnd
preimage := "CtkknKfJ237o8jbippg5NziFZgkUvk9cN20NCuPvqxQ="
// Taken from the same invoice JSON in lnd
expected := "iYYYRTzq0XZgBo1aIAv4KZTzq1PCTmf6nnWvyHMB4C0="
actual, err := ln.HashPreimage(preimage)
if err != nil {
t.Errorf("An error occurred during the test: %v\n", err)
}
if actual != expected {
t.Errorf("Expected %v, but was %v\n", expected, actual)
}
}

0 comments on commit a290870

Please sign in to comment.