address = "GAXEMCEXBERNSRXOEKD4JAIKVECIXQCENHEBRVSPX2TTYZPMNEDSQCNQ" bad = "foo" ) JustBeforeEach(func() { subject = ManageDataBuilder{} subject.Mutate(mut) }) Describe("SourceAccount", func() { Context("using a valid stellar address", func() { BeforeEach(func() { mut = SourceAccount{address} }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred()) }) It("sets the destination to the correct xdr.AccountId", func() { var aid xdr.AccountId aid.SetAddress(address) Expect(subject.O.SourceAccount.MustEd25519()).To(Equal(aid.MustEd25519())) }) }) Context("using an invalid value", func() { BeforeEach(func() { mut = SourceAccount{bad} }) It("failed", func() { Expect(subject.Err).To(HaveOccurred()) }) }) }) })
subject = CreateAccountBuilder{} subject.Mutate(mut) }) Describe("Destination", func() { Context("using a valid stellar address", func() { BeforeEach(func() { mut = Destination{address} }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred()) }) It("sets the destination to the correct xdr.AccountId", func() { var aid xdr.AccountId aid.SetAddress(address) Expect(subject.CA.Destination.MustEd25519()).To(Equal(aid.MustEd25519())) }) }) Context("using an invalid value", func() { BeforeEach(func() { mut = Destination{bad} }) It("failed", func() { Expect(subject.Err).To(HaveOccurred()) }) }) }) Describe("SourceAccount", func() { Context("using a valid stellar address", func() { BeforeEach(func() { mut = SourceAccount{address} }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred())
subject = SetOptionsBuilder{} subject.Mutate(mut) }) Describe("InflationDest", func() { Context("using a valid stellar address", func() { BeforeEach(func() { mut = InflationDest(address) }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred()) }) It("sets the destination to the correct xdr.AccountId", func() { var aid xdr.AccountId aid.SetAddress(address) Expect(subject.SO.InflationDest.MustEd25519()).To(Equal(aid.MustEd25519())) }) }) Context("using an invalid value", func() { BeforeEach(func() { mut = InflationDest(bad) }) It("failed", func() { Expect(subject.Err).To(HaveOccurred()) }) }) }) Describe("Signer", func() { Context("using a valid stellar address", func() { BeforeEach(func() { mut = Signer{address, 5} }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred())
subject = ManageOfferBuilder{} subject.Mutate(mut) }) Describe("CreateOffer", func() { Context("creates offer properly", func() { It("sets values properly", func() { builder := CreateOffer(rate, "20") Expect(builder.MO.Amount).To(Equal(xdr.Int64(200000000))) Expect(builder.MO.Selling.Type).To(Equal(xdr.AssetTypeAssetTypeCreditAlphanum4)) Expect(builder.MO.Selling.AlphaNum4.AssetCode).To(Equal([4]byte{'E', 'U', 'R', 0})) var aid xdr.AccountId aid.SetAddress(rate.Selling.Issuer) Expect(builder.MO.Selling.AlphaNum4.Issuer.MustEd25519()).To(Equal(aid.MustEd25519())) Expect(builder.MO.Selling.AlphaNum12).To(BeNil()) Expect(builder.MO.Buying.Type).To(Equal(xdr.AssetTypeAssetTypeNative)) Expect(builder.MO.Buying.AlphaNum4).To(BeNil()) Expect(builder.MO.Buying.AlphaNum12).To(BeNil()) Expect(builder.MO.Price.N).To(Equal(xdr.Int32(8253))) Expect(builder.MO.Price.D).To(Equal(xdr.Int32(200))) Expect(builder.MO.OfferId).To(Equal(xdr.Uint64(0))) }) }) }) Describe("UpdateOffer", func() {
subject = PaymentBuilder{} subject.Mutate(mut) }) Describe("CreditAmount", func() { Context("AlphaNum4", func() { BeforeEach(func() { mut = CreditAmount{"USD", address, "50.0"} }) It("sets the asset properly", func() { Expect(subject.P.Amount).To(Equal(xdr.Int64(500000000))) Expect(subject.P.Asset.Type).To(Equal(xdr.AssetTypeAssetTypeCreditAlphanum4)) Expect(subject.P.Asset.AlphaNum4.AssetCode).To(Equal([4]byte{'U', 'S', 'D', 0})) var aid xdr.AccountId aid.SetAddress(address) Expect(subject.P.Asset.AlphaNum4.Issuer.MustEd25519()).To(Equal(aid.MustEd25519())) Expect(subject.P.Asset.AlphaNum12).To(BeNil()) }) It("succeeds", func() { Expect(subject.Err).NotTo(HaveOccurred()) }) }) Context("AlphaNum12", func() { BeforeEach(func() { mut = CreditAmount{"ABCDEF", address, "50.0"} }) It("sets the asset properly", func() { Expect(subject.P.Amount).To(Equal(xdr.Int64(500000000))) Expect(subject.P.Asset.Type).To(Equal(xdr.AssetTypeAssetTypeCreditAlphanum12)) Expect(subject.P.Asset.AlphaNum4).To(BeNil())