Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
luyu-chain33-plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
luyu-chain33-plugin
Commits
bf6eae48
Commit
bf6eae48
authored
Mar 04, 2022
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test
parent
80937e11
Pipeline
#8556
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
build.sbt
build.sbt
+3
-0
ChainUtilsSpec.scala
src/test/scala/util/ChainUtilsSpec.scala
+14
-0
UtilsSpec.scala
src/test/scala/util/UtilsSpec.scala
+30
-0
No files found.
build.sbt
View file @
bf6eae48
...
@@ -60,6 +60,9 @@ lazy val root = (project in file("."))
...
@@ -60,6 +60,9 @@ lazy val root = (project in file("."))
"com.typesafe.akka"
%%
"akka-stream"
%
AkkaVersion
,
"com.typesafe.akka"
%%
"akka-stream"
%
AkkaVersion
,
"com.typesafe.akka"
%%
"akka-http"
%
AkkaHttpVersion
,
"com.typesafe.akka"
%%
"akka-http"
%
AkkaHttpVersion
,
"org.typelevel"
%%
"paiges-core"
%
"0.4.2"
,
"com.lihaoyi"
%%
"pprint"
%
"0.7.0"
,
"link.luyu"
%
"luyu-cross-chain-protocol"
%
"1.0.0"
,
"link.luyu"
%
"luyu-cross-chain-protocol"
%
"1.0.0"
,
"link.luyu"
%
"luyu-java-sdk"
%
"1.0.0"
,
"link.luyu"
%
"luyu-java-sdk"
%
"1.0.0"
,
"link.luyu"
%
"luyu-toolkit"
%
"1.0.0"
,
"link.luyu"
%
"luyu-toolkit"
%
"1.0.0"
,
...
...
src/test/scala/util/ChainUtilsSpec.scala
0 → 100644
View file @
bf6eae48
package
util
import
com.chain33.util.ChainUtils
import
org.scalatest.
{
FlatSpec
,
Matchers
}
import
scala.language.postfixOps
class
ChainUtilsSpec
extends
FlatSpec
with
Matchers
{
"ChainUtils"
should
"all test"
in
{
ChainUtils
.
getVersion
shouldEqual
2
ChainUtils
.
getChainId
.
longValue
()
shouldEqual
1
ChainUtils
.
getNonce
nonEmpty
}
}
src/test/scala/util/UtilsSpec.scala
0 → 100644
View file @
bf6eae48
package
util
import
com.chain33.util.Utils
import
org.scalatest.
{
FlatSpec
,
Matchers
}
import
scala.language.postfixOps
class
UtilsSpec
extends
FlatSpec
with
Matchers
{
"utils"
should
"all test"
in
{
val
value
=
Utils
.
longToBytes
(
123
)
Utils
.
bytesToLong
(
value
)
shouldEqual
123
val
value1
=
Utils
.
toByteArray
(
"123"
)
Utils
.
toObject
(
value1
).
asInstanceOf
[
String
]
shouldEqual
"123"
val
codes
=
"608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610651806100326000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806313af4035146100515780637d24e37e14610079578063a8934d79146101a6578063b2bdfa7b146102c1575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166102e5565b005b6100776004803603604081101561008f57600080fd5b8101906020810181356401000000008111156100aa57600080fd5b8201836020820111156100bc57600080fd5b803590602001918460018302840111640100000000831117156100de57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561013157600080fd5b82018360208201111561014357600080fd5b8035906020019184600183028401116401000000008311171561016557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610350945050505050565b61024c600480360360208110156101bc57600080fd5b8101906020810181356401000000008111156101d757600080fd5b8201836020820111156101e957600080fd5b8035906020019184600183028401116401000000008311171561020b57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061045f945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561028657818101518382015260200161026e565b50505050905090810190601f1680156102b35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c9610553565b604080516001600160a01b039092168252519081900360200190f35b6000546001600160a01b0316331461032e5760405162461bcd60e51b81526004018080602001828103825260268152602001806105f66026913960400191505060405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103995760405162461bcd60e51b81526004018080602001828103825260268152602001806105f66026913960400191505060405180910390fd5b8160008151116103e5576040805162461bcd60e51b815260206004820152601260248201527166696c65496420697320696e76616c69642160701b604482015290519081900360640190fd5b816001846040518082805190602001908083835b602083106104185780518252601f1990920191602091820191016103f9565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810190932084516104599591949190910192509050610562565b50505050565b60606001826040518082805190602001908083835b602083106104935780518252601f199092019160209182019101610474565b518151600019602094850361010090810a820192831692199390931691909117909252949092019687526040805197889003820188208054601f60026001831615909802909501169590950492830182900482028801820190528187529294509250508301828280156105475780601f1061051c57610100808354040283529160200191610547565b820191906000526020600020905b81548152906001019060200180831161052a57829003601f168201915b50505050509050919050565b6000546001600160a01b031681565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106105a357805160ff19168380011785556105d0565b828001600101855582156105d0579182015b828111156105d05782518255916020019190600101906105b5565b506105dc9291506105e0565b5090565b5b808211156105dc57600081556001016105e156fe6f6e6c7920617574686f72697a6564206f776e65722063616e2073746f72652066696c65732ea264697066735822122031f48e60df7c860caf840a264a2bf73faebcde84c840a53808e210c386ebde7a64736f6c634300060c0033"
val
abi
=
"[{\"inputs\":[],\"name\":\"_owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"fileId\",\"type\":\"string\"}],\"name\":\"getFileById\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"fileId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"content\",\"type\":\"string\"}],\"name\":\"setFileStockById\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
val
abis
=
Utils
.
parseAbi
(
abi
)
abis
.
isEmpty
shouldEqual
false
println
(
s
"$abis"
)
abis
.
foreach
(
abi
=>
{
pprint
.
pprintln
(
abi
.
name
)
pprint
.
pprintln
(
abi
.
inputTypes
)
pprint
.
pprintln
(
abi
.
outputTypes
)
})
pprint
.
log
(
abis
)
pprint
.
tokenize
(
abis
)
pprint
.
apply
(
abis
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment