Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove independent check of horizon #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions app/concepts/stellar_base/bridge_callbacks/contracts/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,6 @@ class Create < ApplicationContract
validates :from, presence: true
validates :amount, presence: true

validate :check_callback_authenticity

def check_callback_authenticity
if !StellarBase.configuration.check_bridge_callbacks_authenticity
return
end

result = BridgeCallbacks::Check.({
operation_id: operation_id,
transaction_id: transaction_id,
params: {
id: operation_id,
from: from,
route: route,
amount: amount,
asset_code: asset_code,
asset_issuer: asset_issuer,
memo: memo,
memo_type: memo_type,
data: data,
transaction_id: transaction_id,
},
})

errors.add(:base, result.message) if result.failure?
end

end
end
end
Expand Down
17 changes: 0 additions & 17 deletions app/services/stellar_base/bridge_callbacks/check.rb

This file was deleted.

45 changes: 0 additions & 45 deletions app/services/stellar_base/bridge_callbacks/compare.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/services/stellar_base/bridge_callbacks/get_operation.rb

This file was deleted.

23 changes: 0 additions & 23 deletions app/services/stellar_base/bridge_callbacks/get_transaction.rb

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion lib/stellar_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ def self.try_from_yaml_file_path(str)

end

require "stellar_base/horizon_client"
require "stellar_base/rails/routes"
29 changes: 0 additions & 29 deletions lib/stellar_base/horizon_client.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,75 +45,6 @@ module Contracts
end
end

context "if check_bridge_callbacks_authenticity is true" do

before do
StellarBase.configure do |c|
c.check_bridge_callbacks_authenticity = true
end
end

after do
StellarBase.configure do |c|
c.check_bridge_callbacks_authenticity = false
end
end

let(:check_params) do
{
operation_id: "OPERATION_ID_1234",
transaction_id: "TRANSACTION_ID_1234",
params: {
id: "OPERATION_ID_1234",
from: "GABCSENDERXLMADDRESS",
route: "RECIPIENTROUTE",
amount: 100.00,
asset_code: "XLM",
asset_issuer: "GABCASSETISSUER",
memo_type: "id",
memo: "2",
data: "DATAHASH",
transaction_id: "TRANSACTION_ID_1234",
},
}
end
let(:result) { double(LightService::Context) }

context "BridgeCallbacks::Check fails" do
it "gives errors" do
expect(BridgeCallbacks::Check).to receive(:call)
.with(check_params)
.and_return(result)

expect(result).to receive(:failure?).and_return(true)
expect(result).to receive(:message).and_return(
"Operation #1234 doesn't exist"
)

contract = described_class.new(BridgeCallback.new)
contract.validate(params)

expect(contract.errors[:base])
.to include "Operation #1234 doesn't exist"
end
end

context "BridgeCallbacks::Check succeeds" do
it "doesn't return any error" do
expect(BridgeCallbacks::Check).to receive(:call)
.with(check_params)
.and_return(result)

expect(result).to receive(:failure?).and_return(false)

contract = described_class.new(BridgeCallback.new)
contract.validate(params)

expect(contract.errors[:base]).to be_empty
end

end
end
end
end
end
Expand Down
30 changes: 0 additions & 30 deletions spec/fixtures/operation.json

This file was deleted.

45 changes: 0 additions & 45 deletions spec/fixtures/transaction.json

This file was deleted.

Loading