aboutsummaryrefslogtreecommitdiff
path: root/auction_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'auction_test.go')
-rw-r--r--auction_test.go34
1 files changed, 31 insertions, 3 deletions
diff --git a/auction_test.go b/auction_test.go
index 93d9830..04c2590 100644
--- a/auction_test.go
+++ b/auction_test.go
@@ -1,8 +1,36 @@
package seal
-import "testing"
+import (
+ "encoding/json"
+ "strings"
+ "testing"
+ "time"
+)
-func TestAuction(t *testing.T) {
+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)
+ }
+}