aboutsummaryrefslogtreecommitdiff
path: root/auction_test.go
blob: 04c2590704afcce9a3f827b2aac614cd536c8927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package seal

import (
	"encoding/json"
	"strings"
	"testing"
	"time"
)

func TestParseDescription(t *testing.T) {
	var d Description
	var desc = `
	{
		"start": "2024-11-10T15:04:05Z",
		"end": "2024-11-10T18:04:05Z",
		"timeout": "10s",
		"bitlength": 8,
		"currency": "KUDOS",
		"type": 0,
		"seller": "1234"
	}
`
	e := json.NewDecoder(strings.NewReader(desc)).
		Decode(&d)
	if e != nil {
		t.Fatal(e)
	}

	if time.Duration(d.Timeout) != 10*time.Second {
		t.Fatalf("expected timeout 10s, but got: %v", time.Duration(d.Timeout))
	}

	if d.Bitlength != 8 {
		t.Fatalf("expected bitlength %d, but got: %d", 8, d.Bitlength)
	}
}