stellar-sdk 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -208,6 +208,96 @@ describe Stellar::Client do
208
208
  expect(btc_balance).to eq 150.0
209
209
  end
210
210
  end
211
+
212
+ context "memo" do
213
+ let(:destination) { Stellar::Account.random }
214
+
215
+ it("accepts the memo attribute", {
216
+ vcr: {record: :once, match_requests_on: [:method]}
217
+ }) do
218
+ client.create_account(
219
+ funder: source,
220
+ account: destination,
221
+ starting_balance: 100,
222
+ )
223
+
224
+ amount = Stellar::Amount.new(150)
225
+
226
+ client.send_payment(
227
+ from: source,
228
+ to: destination,
229
+ amount: amount,
230
+ memo: "DESUKA",
231
+ )
232
+
233
+ last_tx = client.account_info(destination).
234
+ transactions(order: "desc")._get._embedded.records.first
235
+ expect(last_tx.memo).to eq "DESUKA"
236
+ end
237
+ end
238
+
239
+ context "using a payment channel" do
240
+ let(:transaction_source) { Stellar::Account.from_seed(CONFIG[:channel_seed]) }
241
+ let(:destination) { Stellar::Account.random }
242
+
243
+ it("sends a payment account through a channel account", {
244
+ vcr: {record: :once, match_requests_on: [:method]},
245
+ }) do
246
+ client.create_account(
247
+ funder: source,
248
+ account: destination,
249
+ starting_balance: 1,
250
+ )
251
+
252
+ tx = client.send_payment(
253
+ from: source,
254
+ to: destination,
255
+ amount: Stellar::Amount.new(0.55),
256
+ transaction_source: transaction_source,
257
+ )
258
+
259
+ tx_hash = tx._attributes["hash"]
260
+
261
+ tx = client.horizon.transaction(hash: tx_hash)
262
+ expect(tx.source_account).to eq transaction_source.address
263
+
264
+ operation = tx.operations.records.first
265
+ expect(operation.from).to eq source.address
266
+
267
+ destination_info = client.account_info(destination)
268
+ balances = destination_info.balances
269
+ expect(balances).to_not be_empty
270
+ native_asset_balance_info = balances.find do |b|
271
+ b["asset_type"] == "native"
272
+ end
273
+ expect(native_asset_balance_info["balance"].to_f).to eq 1.55
274
+ end
275
+
276
+ it("sends a payment when the channel is the same as `from`", {
277
+ vcr: {record: :once, match_requests_on: [:method]},
278
+ }) do
279
+ client.create_account(
280
+ funder: source,
281
+ account: destination,
282
+ starting_balance: 1,
283
+ )
284
+
285
+ tx = client.send_payment(
286
+ from: source,
287
+ to: destination,
288
+ amount: Stellar::Amount.new(0.55),
289
+ transaction_source: source,
290
+ )
291
+
292
+ tx_hash = tx._attributes["hash"]
293
+
294
+ tx = client.horizon.transaction(hash: tx_hash)
295
+ expect(tx.source_account).to eq source.address
296
+
297
+ operation = tx.operations.records.first
298
+ expect(operation.from).to eq source.address
299
+ end
300
+ end
211
301
  end
212
302
 
213
303
  describe "#transactions" do
@@ -4,7 +4,7 @@ VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
5
5
  config.hook_into :webmock
6
6
  config.configure_rspec_metadata!
7
- %i[source_address destination_address].each do |var|
7
+ %i[source_address channel_address].each do |var|
8
8
  config.filter_sensitive_data("[#{var}]") { CONFIG[var] }
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stellar-base
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.0
19
+ version: 0.18.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.16.0
26
+ version: 0.18.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hyperclient
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +259,10 @@ files:
259
259
  - spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml
260
260
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml
261
261
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml
262
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/memo/accepts_the_memo_attribute.yml
262
263
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml
264
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_account_through_a_channel_account.yml
265
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_when_the_channel_is_the_same_as_from_.yml
263
266
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml
264
267
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml
265
268
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml
@@ -292,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
295
  version: '0'
293
296
  requirements: []
294
297
  rubyforge_project:
295
- rubygems_version: 2.7.6
298
+ rubygems_version: 2.5.1
296
299
  signing_key:
297
300
  specification_version: 4
298
301
  summary: Stellar client library
@@ -307,7 +310,10 @@ test_files:
307
310
  - spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml
308
311
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml
309
312
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml
313
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/memo/accepts_the_memo_attribute.yml
310
314
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml
315
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_account_through_a_channel_account.yml
316
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_when_the_channel_is_the_same_as_from_.yml
311
317
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml
312
318
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml
313
319
  - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml