Skip to content

Commit

Permalink
fix: tests for FileUpdateTransaction and ConsensusMessageSubmitTransa…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
janaakhterov committed May 27, 2020
1 parent 8773b05 commit 1b0fcb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion consensus_message_submit_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestConsensusMessageSubmitTransaction_Execute(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, info)

assert.Equal(t, uint64(0), info.SequenceNumber)
assert.Equal(t, uint64(1), info.SequenceNumber)

txID, err = NewConsensusTopicDeleteTransaction().
SetTopicID(topicID).
Expand Down
12 changes: 10 additions & 2 deletions file_update_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ type FileUpdateTransaction struct {
}

func NewFileUpdateTransaction() FileUpdateTransaction {
pb := &proto.FileUpdateTransactionBody{Keys: &proto.KeyList{Keys: []*proto.Key{}}}
pb := &proto.FileUpdateTransactionBody{}

inner := newTransactionBuilder()
inner.pb.Data = &proto.TransactionBody_FileUpdate{FileUpdate: pb}

builder := FileUpdateTransaction{inner, pb}
builder.SetExpirationTime(time.Now().Add(7890000 * time.Second))

return builder
}
Expand All @@ -28,7 +27,12 @@ func (builder FileUpdateTransaction) SetFileID(id FileID) FileUpdateTransaction
}

func (builder FileUpdateTransaction) AddKey(publicKey PublicKey) FileUpdateTransaction {
if builder.pb.Keys == nil {
builder.pb.Keys = &proto.KeyList{Keys: []*proto.Key{}}
}

builder.pb.Keys.Keys = append(builder.pb.Keys.Keys, publicKey.toProto())

return builder
}

Expand All @@ -42,6 +46,10 @@ func (builder FileUpdateTransaction) SetContents(contents []byte) FileUpdateTran
return builder
}

func (builder FileUpdateTransaction) Build(client *Client) (Transaction, error) {
return builder.TransactionBuilder.Build(client)
}

//
// The following _5_ must be copy-pasted at the bottom of **every** _transaction.go file
// We override the embedded fluent setter methods to return the outer type
Expand Down

0 comments on commit 1b0fcb2

Please sign in to comment.