示例#1
0
// ClearData removes a key/value pair associated with the source account
func ClearData(name string, muts ...interface{}) (result ManageDataBuilder) {
	result.MD.DataName = xdr.String64(name)
	result.MD.DataValue = nil
	result.validateName()
	result.Mutate(muts...)
	return
}
示例#2
0
// 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
}
示例#3
0
		subject ManageDataBuilder
		name    string
	)

	JustBeforeEach(func() {
		subject = ClearData(name)
	})

	Context("Valid name", func() {
		BeforeEach(func() {
			name = "my data"
		})

		It("succeeds", func() {
			Expect(subject.Err).ToNot(HaveOccurred())
			Expect(subject.MD.DataName).To(Equal(xdr.String64("my data")))
			Expect(subject.MD.DataValue).To(BeNil())
		})
	})

	Context("Long key", func() {
		BeforeEach(func() { name = strings.Repeat("a", 65) })

		It("errors", func() {
			Expect(subject.Err).To(HaveOccurred())
		})
	})

	Context("empty key", func() {
		BeforeEach(func() { name = "" })