Skip to content

Commit

Permalink
update freeze transaction to directly take the hour and minute value
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Jan 30, 2020
1 parent f544f44 commit 399909e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions .snapshots/TestSerializeFreezeTransaction
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bodyBytes: "\n\016\n\010\010\334\311\007\020\333\237\t\022\002\030\003\022\002\030\003\030\300\204=\"\002\010x\272\001\010\010\020\020\n\030\020 \r"
bodyBytes: "\n\016\n\010\010\334\311\007\020\333\237\t\022\002\030\003\022\002\030\003\030\300\204=\"\002\010x\272\001\010\010\014\020\036\030\016 \036"
sigMap: <
sigPair: <
pubKeyPrefix: "\344\361\300\353L}\315\303\347\353\021p\263\010\212=\022\242\227\364\243\353\342\362\205\003\375g5F\355\216"
ed25519: ">\310\024\256\255\014%.\245\367\351\211\325Fy\221\247\352\221\035t\316\354\320'\367\251\371/\215s\t\226\354\355\360\312\363\001\037,\036\014\347\303\306l\375\016\3025\276\235c7r\274\213\350f\021u\337\r"
ed25519: "\236\2040\201\314\033\272\346\250Zi$\240\016\322!\351\211\342\000[z\036\346\345\314,\220\314F0\377\356\370k*\020\270I\320\273<zp\260\241~\255\204L\274\272\2328\240\004\256\356\3603+\200\r\005"
>
>
transactionID: <
Expand All @@ -22,9 +22,9 @@ transactionValidDuration: <
seconds: 120
>
freeze: <
startHour: 16
startMin: 10
endHour: 16
endMin: 13
startHour: 12
startMin: 30
endHour: 14
endMin: 30
>

12 changes: 6 additions & 6 deletions freeze_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func NewFreezeTransaction() FreezeTransaction {
return builder
}

func (builder FreezeTransaction) SetStartTime(start time.Time) FreezeTransaction {
builder.pb.StartHour = int32(start.Hour())
builder.pb.StartMin = int32(start.Minute())
func (builder FreezeTransaction) SetStartTime(hour uint8, minute uint8) FreezeTransaction {
builder.pb.StartHour = int32(hour)
builder.pb.StartMin = int32(minute)
return builder
}

func (builder FreezeTransaction) SetEndTime(end time.Time) FreezeTransaction {
builder.pb.EndHour = int32(end.Hour())
builder.pb.EndMin = int32(end.Minute())
func (builder FreezeTransaction) SetEndTime(hour uint8, minute uint8) FreezeTransaction {
builder.pb.EndHour = int32(hour)
builder.pb.EndMin = int32(minute)
return builder
}

Expand Down
5 changes: 2 additions & 3 deletions freeze_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/bradleyjkemp/cupaloy"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestSerializeFreezeTransaction(t *testing.T) {
Expand All @@ -16,8 +15,8 @@ func TestSerializeFreezeTransaction(t *testing.T) {

tx := NewFreezeTransaction().
SetTransactionID(testTransactionID).
SetStartTime(time.Unix(600, 100)).
SetEndTime(time.Unix(800, 100)).
SetStartTime(12, 30).
SetEndTime(14, 30).
SetMaxTransactionFee(HbarFromTinybar(1e6)).
SetTransactionID(testTransactionID).
Build(mockClient).
Expand Down

0 comments on commit 399909e

Please sign in to comment.