Skip to content

Commit

Permalink
chore: add default padding to base64 oracles response/queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sborrazas committed Sep 9, 2024
1 parent fbc084c commit bcc03e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/ae_mdw/oracles.ex
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ defmodule AeMdw.Oracles do
query_id: Enc.encode(:oracle_query_id, query_id)
}
|> Map.merge(:aeo_query_tx.for_client(query_tx))
|> update_in(["query"], &Base.encode64(&1, padding: false))
|> update_in(["query"], &Base.encode64/1)

if include_response? do
Map.put(
Expand Down Expand Up @@ -223,7 +223,7 @@ defmodule AeMdw.Oracles do
query_id: Enc.encode(:oracle_query_id, query_id)
}
|> Map.merge(:aeo_response_tx.for_client(response_tx))
|> update_in(["response"], &Base.encode64(&1, padding: false))
|> update_in(["response"], &Base.encode64/1)

if include_query? do
Map.put(response, :query, render_query(state, {oracle_pk, query_id}, false))
Expand Down
12 changes: 6 additions & 6 deletions test/ae_mdw_web/controllers/oracle_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ defmodule AeMdwWeb.OracleControllerTest do
"query_fee" => 11,
"sender_id" => ^encoded_account_id1,
"source_tx_type" => "OracleQueryTx",
"query" => "cXVlcnktMQ",
"query" => "cXVlcnktMQ==",
"fee" => 11_111,
"block_time" => 123
} = oracle1
Expand All @@ -568,7 +568,7 @@ defmodule AeMdwWeb.OracleControllerTest do
"query_fee" => 22,
"sender_id" => ^encoded_account_id2,
"source_tx_type" => "ContractCallTx",
"query" => "cXVlcnktMg",
"query" => "cXVlcnktMg==",
"fee" => 22_222,
"block_time" => 123
} = oracle2
Expand Down Expand Up @@ -804,7 +804,7 @@ defmodule AeMdwWeb.OracleControllerTest do

assert %{
"oracle_id" => ^encoded_oracle_pk,
"response" => "cmVzcG9uc2UtMQ",
"response" => "cmVzcG9uc2UtMQ==",
"block_time" => 123,
"height" => 2,
"query" => %{
Expand All @@ -815,14 +815,14 @@ defmodule AeMdwWeb.OracleControllerTest do
"query_fee" => 11,
"sender_id" => ^encoded_account_id1,
"source_tx_type" => "OracleQueryTx",
"query" => "cXVlcnktMQ",
"query" => "cXVlcnktMQ==",
"fee" => 11_111
}
} = response1

assert %{
"oracle_id" => ^encoded_oracle_pk,
"response" => "cmVzcG9uc2UtMg",
"response" => "cmVzcG9uc2UtMg==",
"block_time" => 123,
"height" => 2,
"query" => %{
Expand All @@ -833,7 +833,7 @@ defmodule AeMdwWeb.OracleControllerTest do
"query_fee" => 22,
"sender_id" => ^encoded_account_id2,
"source_tx_type" => "ContractCallTx",
"query" => "cXVlcnktMg",
"query" => "cXVlcnktMg==",
"fee" => 22_222
}
} = response2
Expand Down

0 comments on commit bcc03e9

Please sign in to comment.