Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
69612370
Unverified
Commit
69612370
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
client: add construction test for CallTx
parent
00628e35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/core/transaction_factory_test.go
+53
-21
53 additions, 21 deletions
client/core/transaction_factory_test.go
with
53 additions
and
21 deletions
client/core/transaction_factory_test.go
+
53
−
21
View file @
69612370
...
...
@@ -24,25 +24,23 @@ import (
mockkeys
"github.com/eris-ltd/eris-db/keys/mock"
)
// func TestTransactionFactory(t *testing.T) {
// // test in parallel
// t.Run("ExtractInputAddress from transaction", func (t1 *testing.T) {
// t1.Run("SendTransaction", testTransactionFactorySend)
// // t.Run("NameTransaction", )
// // t.Run("CallTransaction", )
// // t.Run("PermissionTransaction", )
// // t.Run("BondTransaction", )
// // t.Run("UnbondTransaction", )
// // t.Run("RebondTransaction", )
// })
// }
func
TestTransactionFactorySend
(
t
*
testing
.
T
)
{
func
TestTransactionFactory
(
t
*
testing
.
T
)
{
mockKeyClient
:=
mockkeys
.
NewMockKeyClient
()
mockNodeClient
:=
mockclient
.
NewMockNodeClient
()
testTransactionFactorySend
(
t
,
mockNodeClient
,
mockKeyClient
)
// t.Run("NameTransaction", )
testTransactionFactoryCall
(
t
,
mockNodeClient
,
mockKeyClient
)
// t.Run("PermissionTransaction", )
// t.Run("BondTransaction", )
// t.Run("UnbondTransaction", )
// t.Run("RebondTransaction", )
}
func
testTransactionFactorySend
(
t
*
testing
.
T
,
nodeClient
*
mockclient
.
MockNodeClient
,
keyClient
*
mockkeys
.
MockKeyClient
)
{
// generate an ED25519 key and ripemd160 address
addressString
:=
fmt
.
Sprintf
(
"%X"
,
mockK
eyClient
.
NewKey
())
addressString
:=
fmt
.
Sprintf
(
"%X"
,
k
eyClient
.
NewKey
())
// Public key can be queried from mockKeyClient.PublicKey(address)
// but here we let the transaction factory retrieve the public key
// which will then also overwrite the address we provide the function.
...
...
@@ -50,16 +48,50 @@ func TestTransactionFactorySend(t *testing.T) {
// to address in generated transation.
publicKeyString
:=
""
// generate an additional address to send amount to
toAddressString
:=
fmt
.
Sprintf
(
"%X"
,
mockK
eyClient
.
NewKey
())
toAddressString
:=
fmt
.
Sprintf
(
"%X"
,
k
eyClient
.
NewKey
())
// set an amount to transfer
amount
:=
"1000"
amount
String
:=
"1000"
// unset nonce so that we retrieve nonce from account
nonce
:=
""
nonce
String
:=
""
_
,
err
:=
Send
(
mockN
odeClient
,
mockK
eyClient
,
publicKeyString
,
addressString
,
toAddressString
,
amount
,
nonce
)
_
,
err
:=
Send
(
n
odeClient
,
k
eyClient
,
publicKeyString
,
addressString
,
toAddressString
,
amount
String
,
nonce
String
)
if
err
!=
nil
{
t
.
Logf
(
"Error: %s"
,
err
)
t
.
Logf
(
"Error
in SendTx
: %s"
,
err
)
t
.
Fail
()
}
// TODO: test content of Transaction
}
func
testTransactionFactoryCall
(
t
*
testing
.
T
,
nodeClient
*
mockclient
.
MockNodeClient
,
keyClient
*
mockkeys
.
MockKeyClient
)
{
// generate an ED25519 key and ripemd160 address
addressString
:=
fmt
.
Sprintf
(
"%X"
,
keyClient
.
NewKey
())
// Public key can be queried from mockKeyClient.PublicKey(address)
// but here we let the transaction factory retrieve the public key
// which will then also overwrite the address we provide the function.
// As a result we will assert whether address generated above, is identical
// to address in generated transation.
publicKeyString
:=
""
// generate an additional address to send amount to
toAddressString
:=
fmt
.
Sprintf
(
"%X"
,
keyClient
.
NewKey
())
// set an amount to transfer
amountString
:=
"1000"
// unset nonce so that we retrieve nonce from account
nonceString
:=
""
// set gas
gasString
:=
"1000"
// set fee
feeString
:=
"100"
// set data
dataString
:=
fmt
.
Sprintf
(
"%X"
,
"We are DOUG."
)
_
,
err
:=
Call
(
nodeClient
,
keyClient
,
publicKeyString
,
addressString
,
toAddressString
,
amountString
,
nonceString
,
gasString
,
feeString
,
dataString
)
if
err
!=
nil
{
t
.
Logf
(
"Error in CallTx: %s"
,
err
)
t
.
Fail
()
}
// TODO: test content of Transaction
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment