Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Commit

Permalink
style: format test files
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Jul 16, 2018
1 parent 5303777 commit 57358a2
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .formatter.exs
@@ -1,4 +1,4 @@
# Used by "mix format"
[
inputs: ["mix.exs", "{lib}/**/*.{ex,exs}"]
inputs: ["mix.exs", "{lib,test}/**/*.{ex,exs}"]
]
4 changes: 1 addition & 3 deletions test/crypto/identities/address_test.exs
Expand Up @@ -4,9 +4,7 @@ defmodule ArkEcosystem.Crypto.Identities.AddressTest do
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end
Expand Down
73 changes: 43 additions & 30 deletions test/crypto/transactions/builder_test.exs
Expand Up @@ -10,7 +10,7 @@ defmodule ArkEcosystem.Crypto.Transactions.BuilderTest do
{
:ok,
[
amount: 133380000000,
amount: 133_380_000_000,
recipient_id: "AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
vendor_field: "This is a transaction from Elixir",
secret: "this is a top secret passphrase",
Expand All @@ -21,24 +21,26 @@ defmodule ArkEcosystem.Crypto.Transactions.BuilderTest do
end

test "should build transfer and verify", context do
transaction = Builder.build_transfer(
context[:recipient_id],
context[:amount],
context[:vendor_field],
context[:secret]
)
transaction =
Builder.build_transfer(
context[:recipient_id],
context[:amount],
context[:vendor_field],
context[:secret]
)

assert(Transaction.verify(transaction) == true)
end

test "should build transfer and verfiy with second secret", context do
transaction = Builder.build_transfer(
context[:recipient_id],
context[:amount],
context[:vendor_field],
context[:secret],
context[:second_secret]
)
transaction =
Builder.build_transfer(
context[:recipient_id],
context[:amount],
context[:vendor_field],
context[:secret],
context[:second_secret]
)

second_public_key_address = PublicKey.from_passphrase(context[:second_secret])

Expand All @@ -49,19 +51,24 @@ defmodule ArkEcosystem.Crypto.Transactions.BuilderTest do
test "should build vote and verify", context do
votes = ["+" <> context[:delegate]]

transaction = Builder.build_vote(
votes, context[:secret]
)
transaction =
Builder.build_vote(
votes,
context[:secret]
)

assert(Transaction.verify(transaction) == true)
end

test "should build vote and verify with second secret", context do
votes = ["+" <> context[:delegate]]

transaction = Builder.build_vote(
votes, context[:secret], context[:second_secret]
)
transaction =
Builder.build_vote(
votes,
context[:secret],
context[:second_secret]
)

second_public_key_address = PublicKey.from_passphrase(context[:second_secret])

Expand All @@ -70,9 +77,11 @@ defmodule ArkEcosystem.Crypto.Transactions.BuilderTest do
end

test "should build second signature registration and verify", context do
transaction = Builder.build_second_signature_registration(
context[:secret], context[:second_secret]
)
transaction =
Builder.build_second_signature_registration(
context[:secret],
context[:second_secret]
)

second_public_key_address = PublicKey.from_passphrase(context[:second_secret])

Expand All @@ -81,22 +90,26 @@ defmodule ArkEcosystem.Crypto.Transactions.BuilderTest do
end

test "should build delegate registration and verify", context do
transaction = Builder.build_delegate_registration(
"Moo", context[:secret]
)
transaction =
Builder.build_delegate_registration(
"Moo",
context[:secret]
)

assert(Transaction.verify(transaction) == true)
end

test "should build delegate registration and verify with second secret", context do
transaction = Builder.build_delegate_registration(
"Moo", context[:secret], context[:second_secret]
)
transaction =
Builder.build_delegate_registration(
"Moo",
context[:secret],
context[:second_secret]
)

second_public_key_address = PublicKey.from_passphrase(context[:second_secret])

assert(Transaction.verify(transaction) == true)
assert(Transaction.second_verify(transaction, second_public_key_address) == true)
end

end
Expand Up @@ -34,5 +34,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.DelegateRegistrationTes
assert(actual.id == fixture.data.id)
assert(actual.asset.delegate.username == fixture.data.asset.delegate.username)
end

end
Expand Up @@ -10,5 +10,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.DelegateResignationTest

assert(actual.id == fixture.data.id)
end

end
1 change: 0 additions & 1 deletion test/crypto/transactions/deserializers/ipfs_test.exs
Expand Up @@ -10,5 +10,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.IPFSTest do

assert(actual.id == fixture.data.id)
end

end
Expand Up @@ -10,5 +10,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.MultiPaymentTest do

assert(actual.id == fixture.data.id)
end

end
@@ -1,26 +1,25 @@
defmodule ArkEcosystem.Crypto.Transactions.Deserializers.MultiSignatureRegistrationTest do
use ExUnit.Case, async: false
alias ArkEcosystem.Crypto.Transactions.Deserializer
alias ArkEcosystem.Test.TestHelper
use ExUnit.Case, async: false
alias ArkEcosystem.Crypto.Transactions.Deserializer
alias ArkEcosystem.Test.TestHelper

test "should be ok if signed with a passphrase" do
fixture = TestHelper.read_transaction_fixture("multi_signature_registration", "passphrase")
actual = Deserializer.deserialize(fixture)

assert(actual.version == 1)
assert(actual.network == 23)
assert(actual.type == fixture.data.type)
assert(actual.timestamp == fixture.data.timestamp)
assert(actual.sender_public_key == fixture.data.senderPublicKey)
assert(actual.fee == fixture.data.fee)
assert(actual.amount == fixture.data.amount)
assert(actual.id == fixture.data.id)
assert(actual.signature == fixture.data.signature)
assert(actual.sign_signature == fixture.data.signSignature)
assert(actual.signatures == fixture.data.signatures)
assert(actual.asset.multisignature.keysgroup == fixture.data.asset.multisignature.keysgroup)
assert(actual.asset.multisignature.min == fixture.data.asset.multisignature.min)
assert(actual.asset.multisignature.lifetime == fixture.data.asset.multisignature.lifetime)
end
test "should be ok if signed with a passphrase" do
fixture = TestHelper.read_transaction_fixture("multi_signature_registration", "passphrase")
actual = Deserializer.deserialize(fixture)

assert(actual.version == 1)
assert(actual.network == 23)
assert(actual.type == fixture.data.type)
assert(actual.timestamp == fixture.data.timestamp)
assert(actual.sender_public_key == fixture.data.senderPublicKey)
assert(actual.fee == fixture.data.fee)
assert(actual.amount == fixture.data.amount)
assert(actual.id == fixture.data.id)
assert(actual.signature == fixture.data.signature)
assert(actual.sign_signature == fixture.data.signSignature)
assert(actual.signatures == fixture.data.signatures)
assert(actual.asset.multisignature.keysgroup == fixture.data.asset.multisignature.keysgroup)
assert(actual.asset.multisignature.min == fixture.data.asset.multisignature.min)
assert(actual.asset.multisignature.lifetime == fixture.data.asset.multisignature.lifetime)
end
end
Expand Up @@ -5,7 +5,9 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.SecondSignatureRegistra
alias ArkEcosystem.Test.TestHelper

test "should be ok if signed with a passphrase" do
fixture = TestHelper.read_transaction_fixture("second_signature_registration", "second-passphrase")
fixture =
TestHelper.read_transaction_fixture("second_signature_registration", "second-passphrase")

actual = Deserializer.deserialize(fixture)

assert(actual.version == 1)
Expand All @@ -22,5 +24,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.SecondSignatureRegistra
# special case as the type 1 transaction itself has no recipientId
assert(actual.recipient_id == Address.from_public_key(fixture.data.senderPublicKey))
end

end
Expand Up @@ -10,5 +10,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.TimelockTransferTest do

assert(actual.id == fixture.data.id)
end

end
9 changes: 6 additions & 3 deletions test/crypto/transactions/deserializers/transfer_test.exs
Expand Up @@ -56,7 +56,9 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.TransferTest do
end

test "should be ok if signed with a second passphrase and vendor field" do
fixture = TestHelper.read_transaction_fixture("transfer", "second-passphrase-with-vendor-field")
fixture =
TestHelper.read_transaction_fixture("transfer", "second-passphrase-with-vendor-field")

actual = Deserializer.deserialize(fixture)

assert(actual.version == 1)
Expand Down Expand Up @@ -93,7 +95,9 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.TransferTest do
end

test "should be ok if signed with a second passphrase and vendor field hex" do
fixture = TestHelper.read_transaction_fixture("transfer", "second-passphrase-with-vendor-field-hex")
fixture =
TestHelper.read_transaction_fixture("transfer", "second-passphrase-with-vendor-field-hex")

actual = Deserializer.deserialize(fixture)

assert(actual.version == 1)
Expand All @@ -110,5 +114,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.TransferTest do
assert(actual.sign_signature == fixture.data.signSignature)
assert(actual.id == fixture.data.id)
end

end
1 change: 0 additions & 1 deletion test/crypto/transactions/deserializers/vote_test.exs
Expand Up @@ -37,5 +37,4 @@ defmodule ArkEcosystem.Crypto.Transactions.Deserializers.VoteTest do
assert(actual.id == fixture.data.id)
assert(actual.asset.votes == fixture.data.asset.votes)
end

end
Expand Up @@ -4,18 +4,15 @@ defmodule ArkEcosystem.Crypto.Transactions.Serializers.DelegateRegistrationTest
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end

test "should be ok" do
fixture = TestHelper.read_transaction_fixture("delegate_registration", "passphrase")
actual = Serializer.serialize(fixture.data, %{ underscore: true })
actual = Serializer.serialize(fixture.data, %{underscore: true})

assert(actual == fixture.serialized)
end

end
Expand Up @@ -4,19 +4,16 @@ defmodule ArkEcosystem.Crypto.Transactions.Serializers.DelegateResignationTest d
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end

@tag :skip
test "should be ok" do
fixture = TestHelper.read_transaction_fixture("delegate_resignation", "passphrase")
actual = Serializer.serialize(fixture.data, %{ underscore: true })
actual = Serializer.serialize(fixture.data, %{underscore: true})

assert(actual == fixture.serialized)
end

end
7 changes: 2 additions & 5 deletions test/crypto/transactions/serializers/ipfs_test.exs
Expand Up @@ -4,19 +4,16 @@ defmodule ArkEcosystem.Crypto.Transactions.Serializers.IPFSTest do
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end

@tag :skip
test "should be ok" do
fixture = TestHelper.read_transaction_fixture("ipfs", "passphrase")
actual = Serializer.serialize(fixture.data, %{ underscore: true })
actual = Serializer.serialize(fixture.data, %{underscore: true})

assert(actual == fixture.serialized)
end

end
7 changes: 2 additions & 5 deletions test/crypto/transactions/serializers/multi_payment_test.exs
Expand Up @@ -4,19 +4,16 @@ defmodule ArkEcosystem.Crypto.Transactions.Serializers.MultiPaymentTest do
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end

@tag :skip
test "should be ok" do
fixture = TestHelper.read_transaction_fixture("multi_payment", "passphrase")
actual = Serializer.serialize(fixture.data, %{ underscore: true })
actual = Serializer.serialize(fixture.data, %{underscore: true})

assert(actual == fixture.serialized)
end

end
Expand Up @@ -4,18 +4,15 @@ defmodule ArkEcosystem.Crypto.Transactions.Serializers.MultiSignatureRegistratio
alias ArkEcosystem.Test.TestHelper

setup_all do
ArkEcosystem.Crypto.Configuration.Network.set(
ArkEcosystem.Crypto.Networks.Devnet
)
ArkEcosystem.Crypto.Configuration.Network.set(ArkEcosystem.Crypto.Networks.Devnet)

:ok
end

test "should be ok" do
fixture = TestHelper.read_transaction_fixture("multi_signature_registration", "passphrase")
actual = Serializer.serialize(fixture.data, %{ underscore: true })
actual = Serializer.serialize(fixture.data, %{underscore: true})

assert(actual == fixture.serialized)
end

end

0 comments on commit 57358a2

Please sign in to comment.