コード例 #1
0
ファイル: manage_data.go プロジェクト: stellar/bridge-server
// SetData sets a key/value pair associated with the source account, updating it
// if one already exists.
func SetData(name string, value []byte, muts ...interface{}) (result ManageDataBuilder) {
	result.MD.DataName = xdr.String64(name)
	v := xdr.DataValue(value)
	result.MD.DataValue = &v
	result.validateName()
	result.validateValue()
	result.Mutate(muts...)
	return
}
コード例 #2
0
	)

	JustBeforeEach(func() {
		subject = SetData(name, value)
	})

	Context("Valid name and value", func() {
		BeforeEach(func() {
			name = "my data"
			value = []byte{0xFF, 0xFF}
		})

		It("succeeds", func() {
			Expect(subject.Err).ToNot(HaveOccurred())
			Expect(subject.MD.DataName).To(Equal(xdr.String64("my data")))
			Expect(*subject.MD.DataValue).To(Equal(xdr.DataValue([]byte{0xFF, 0xFF})))
		})
	})

	Context("empty value", func() {
		BeforeEach(func() {
			name = "some name"
			value = []byte{}
		})

		It("succeeds", func() {
			Expect(subject.Err).ToNot(HaveOccurred())
			Expect(subject.MD.DataName).To(Equal(xdr.String64("some name")))
		})
	})