Skip to content

Commit

Permalink
Merge pull request #366 from YazzyYaz/time_bound_transactions
Browse files Browse the repository at this point in the history
Timebounds On Transactions
  • Loading branch information
bartekn authored Mar 15, 2018
2 parents 081dd9c + 461593e commit e64c35d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ type Thresholds struct {
High *uint32
}

type Timebounds struct {
MinTime uint64
MaxTime uint64
}

// Trustor is a mutator capable of setting the trustor on
// allow_trust operation.
type Trustor struct {
Expand Down
5 changes: 5 additions & 0 deletions build/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ func (m MemoText) MutateTransaction(o *TransactionBuilder) (err error) {
return
}

func (m Timebounds) MutateTransaction(o *TransactionBuilder) error {
o.TX.TimeBounds = &xdr.TimeBounds{MinTime: xdr.Uint64(m.MinTime), MaxTime: xdr.Uint64(m.MaxTime)}
return nil
}

// MutateTransaction for Network sets the Network ID to use when signing this transaction
func (m Network) MutateTransaction(o *TransactionBuilder) error {
o.NetworkPassphrase = m.Passphrase
Expand Down
9 changes: 9 additions & 0 deletions build/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ var _ = Describe("Transaction Mutators:", func() {
})
})

Describe("Timebounds", func() {
BeforeEach(func() { mut = Timebounds{1521056118, 1521056298} })
It("succeeds", func() { Expect(err).NotTo(HaveOccurred()) })
It("sets an minimum and maximum timebound on the transaction", func() {
Expect(subject.TX.TimeBounds.MinTime).To(Equal(xdr.Uint64(1521056118)))
Expect(subject.TX.TimeBounds.MaxTime).To(Equal(xdr.Uint64(1521056298)))
})
})

Describe("AllowTrustBuilder", func() {
BeforeEach(func() { mut = AllowTrust() })
It("adds itself to the tx's operations", func() {
Expand Down

0 comments on commit e64c35d

Please sign in to comment.