Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
Fix NonceFromJson with a passed in NewNonce (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikaela <[email protected]>

Co-authored-by: Philip Feairheller <[email protected]>
  • Loading branch information
Mikaela Tarkocheva and pfeairheller authored Dec 10, 2020
1 parent d1d4d04 commit dbda9c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/libursa/ursa/ursa.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package ursa
*/
import "C"
import (
"fmt"
"unsafe"

"github.com/pkg/errors"
Expand All @@ -34,7 +33,7 @@ func NewNonce() (*Nonce, error) {
//NonceFromJson creates and returns nonce json
func NonceFromJSON(jsn string) (*Nonce, error) {
var handle unsafe.Pointer
cjson := C.CString(fmt.Sprintf(`"%s"`, jsn))
cjson := C.CString(jsn)
defer C.free(unsafe.Pointer(cjson))

result := C.ursa_cl_nonce_from_json(cjson, &handle)
Expand Down
11 changes: 11 additions & 0 deletions pkg/libursa/ursa/ursa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ func TestNonceFromJSON(t *testing.T) {
assert.Empty(t, n)
assert.NotEmpty(t, err)
})

t.Run("Pass NonceToJson", func(t *testing.T) {
n, err := NewNonce()
assert.Empty(t, err)
assert.NotEmpty(t, n)


noncePtr, err := NonceFromJson(n)
assert.Empty(t, err)
assert.NotEmpty(t, noncePtr)
})
}

func TestCredentialKeyCorrectnessProofFromJSON(t *testing.T) {
Expand Down

0 comments on commit dbda9c8

Please sign in to comment.