コード例 #1
0
ファイル: bundle_test.go プロジェクト: stellar/bridge-server
	BeforeEach(func() {
		err := newAccount.SetAddress("GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU")
		Expect(err).ToNot(HaveOccurred())
		err = masterAccount.SetAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")
		Expect(err).ToNot(HaveOccurred())
		err = nonexistantAccount.SetAddress("GDGAWQZT2RALG2XBEESTMA7PHDASK4EZGXWGBCIHZRSGGLZOGZGV5JL3")
		Expect(err).ToNot(HaveOccurred())
		err = gatewayAccount.SetAddress("GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")
		Expect(err).ToNot(HaveOccurred())
	})

	Describe("InitialState", func() {

		It("errors when `key` does not appear in the bundle", func() {
			_, err := createAccount.InitialState(nonexistantAccount.LedgerKey())
			Expect(err).To(MatchError("meta: no changes found"))
		})

		It("returns nil if `key` gets created within the bundle", func() {
			found, err := createAccount.InitialState(newAccount.LedgerKey())
			Expect(err).ToNot(HaveOccurred())
			Expect(found).To(BeNil())
		})

		It("returns the state if found", func() {
			found, err := createAccount.InitialState(masterAccount.LedgerKey())
			Expect(err).ToNot(HaveOccurred())
			Expect(found).ToNot(BeNil())
			Expect(found.Data.Type).To(Equal(xdr.LedgerEntryTypeAccount))