Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hive-ruby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hive-ruby
Commits
d569c417
Commit
d569c417
authored
6 years ago
by
Anthony Martin
Browse files
Options
Downloads
Patches
Plain Diff
expanded live stream testing
parent
63c778fb
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
Rakefile
+128
-31
128 additions, 31 deletions
Rakefile
with
128 additions
and
31 deletions
Rakefile
+
128
−
31
View file @
d569c417
...
@@ -138,44 +138,141 @@ end
...
@@ -138,44 +138,141 @@ end
namespace
:stream
do
namespace
:stream
do
desc
'Test the ability to stream a block range.'
desc
'Test the ability to stream a block range.'
task
:block_range
do
task
:block_range
,
[
:mode
,
:at_block_num
]
do
|
t
,
args
|
block_api
=
Steem
::
BlockApi
.
new
(
url:
ENV
[
'TEST_NODE'
])
mode
=
(
args
[
:mode
]
||
'irreversible'
).
to_sym
first_block_num
=
args
[
:at_block_num
].
to_i
if
!!
args
[
:at_block_num
]
stream
=
Steem
::
Stream
.
new
(
url:
ENV
[
'TEST_NODE'
],
mode:
mode
)
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
last_block_num
=
nil
last_block_num
=
nil
first_block_num
=
nil
last_timestamp
=
nil
last_timestamp
=
nil
range_complete
=
false
loop
do
api
.
get_dynamic_global_properties
do
|
properties
|
api
.
get_dynamic_global_properties
do
|
properties
|
current_block_num
=
if
mode
==
:head
current_block_num
=
properties
.
last_irreversible_block_num
properties
.
head_block_number
# First pass replays latest a random number of blocks to test chunking.
else
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
properties
.
last_irreversible_block_num
end
# First pass replays latest a random number of blocks to test chunking.
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
range
=
first_block_num
..
current_block_num
puts
"Initial block range:
#{
range
.
size
}
"
stream
.
blocks
(
at_block_num:
range
.
first
)
do
|
block
,
block_num
|
current_timestamp
=
Time
.
parse
(
block
.
timestamp
+
'Z'
)
if
current_block_num
>=
first_block_num
if
!
range_complete
&&
block_num
>
range
.
last
range
=
first_block_num
..
current_block_num
puts
'Done with initial range.'
puts
"Got block range:
#{
range
.
size
}
"
range_complete
=
true
block_api
.
get_blocks
(
block_range:
range
)
do
|
block
,
block_num
|
current_timestamp
=
Time
.
parse
(
block
.
timestamp
+
'Z'
)
if
!!
last_timestamp
&&
block_num
!=
last_block_num
+
1
puts
"Bug: Last block number was
#{
last_block_num
}
then jumped to:
#{
block_num
}
"
exit
end
if
!!
last_timestamp
&&
current_timestamp
<
last_timestamp
puts
"Bug: Went back in time. Last timestamp was
#{
last_timestamp
}
, then jumped back to
#{
current_timestamp
}
"
exit
end
puts
"
\t
#{
block_num
}
Timestamp:
#{
current_timestamp
}
, witness:
#{
block
.
witness
}
"
last_block_num
=
block_num
last_timestamp
=
current_timestamp
end
first_block_num
=
range
.
max
+
1
end
end
sleep
3
if
!!
last_timestamp
&&
block_num
!=
last_block_num
+
1
puts
"Bug: Last block number was
#{
last_block_num
}
then jumped to:
#{
block_num
}
"
exit
end
if
!!
last_timestamp
&&
current_timestamp
<
last_timestamp
puts
"Bug: Went back in time. Last timestamp was
#{
last_timestamp
}
, then jumped back to
#{
current_timestamp
}
"
exit
end
puts
"
\t
#{
block_num
}
Timestamp:
#{
current_timestamp
}
, witness:
#{
block
.
witness
}
"
last_block_num
=
block_num
last_timestamp
=
current_timestamp
end
end
end
desc
'Test the ability to stream a block range of transactions.'
task
:trx_range
,
[
:mode
,
:at_block_num
]
do
|
t
,
args
|
mode
=
(
args
[
:mode
]
||
'irreversible'
).
to_sym
first_block_num
=
args
[
:at_block_num
].
to_i
if
!!
args
[
:at_block_num
]
stream
=
Steem
::
Stream
.
new
(
url:
ENV
[
'TEST_NODE'
],
mode:
mode
)
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
api
.
get_dynamic_global_properties
do
|
properties
|
current_block_num
=
if
mode
==
:head
properties
.
head_block_number
else
properties
.
last_irreversible_block_num
end
# First pass replays latest a random number of blocks to test chunking.
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
stream
.
transactions
(
at_block_num:
first_block_num
)
do
|
trx
,
trx_id
,
block_num
|
puts
"
#{
block_num
}
::
#{
trx_id
}
; ops:
#{
trx
.
operations
.
map
(
&
:type
).
join
(
', '
)
}
"
end
end
end
desc
'Test the ability to stream a block range of operations.'
task
:op_range
,
[
:mode
,
:at_block_num
]
do
|
t
,
args
|
mode
=
(
args
[
:mode
]
||
'irreversible'
).
to_sym
first_block_num
=
args
[
:at_block_num
].
to_i
if
!!
args
[
:at_block_num
]
stream
=
Steem
::
Stream
.
new
(
url:
ENV
[
'TEST_NODE'
],
mode:
mode
)
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
api
.
get_dynamic_global_properties
do
|
properties
|
current_block_num
=
if
mode
==
:head
properties
.
head_block_number
else
properties
.
last_irreversible_block_num
end
# First pass replays latest a random number of blocks to test chunking.
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
stream
.
operations
(
at_block_num:
first_block_num
)
do
|
op
,
trx_id
,
block_num
|
puts
"
#{
block_num
}
::
#{
trx_id
}
; op:
#{
op
.
type
}
"
end
end
end
desc
'Test the ability to stream a block range of virtual operations.'
task
:vop_range
,
[
:mode
,
:at_block_num
]
do
|
t
,
args
|
mode
=
(
args
[
:mode
]
||
'irreversible'
).
to_sym
first_block_num
=
args
[
:at_block_num
].
to_i
if
!!
args
[
:at_block_num
]
stream
=
Steem
::
Stream
.
new
(
url:
ENV
[
'TEST_NODE'
],
mode:
mode
)
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
api
.
get_dynamic_global_properties
do
|
properties
|
current_block_num
=
if
mode
==
:head
properties
.
head_block_number
else
properties
.
last_irreversible_block_num
end
# First pass replays latest a random number of blocks to test chunking.
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
stream
.
operations
(
at_block_num:
first_block_num
,
only_virtual:
true
)
do
|
op
,
trx_id
,
block_num
|
puts
"
#{
block_num
}
::
#{
trx_id
}
; op:
#{
op
.
type
}
"
end
end
end
desc
'Test the ability to stream a block range of all operations (including virtual).'
task
:all_op_range
,
[
:mode
,
:at_block_num
]
do
|
t
,
args
|
mode
=
(
args
[
:mode
]
||
'irreversible'
).
to_sym
first_block_num
=
args
[
:at_block_num
].
to_i
if
!!
args
[
:at_block_num
]
stream
=
Steem
::
Stream
.
new
(
url:
ENV
[
'TEST_NODE'
],
mode:
mode
)
api
=
Steem
::
Api
.
new
(
url:
ENV
[
'TEST_NODE'
])
api
.
get_dynamic_global_properties
do
|
properties
|
current_block_num
=
if
mode
==
:head
properties
.
head_block_number
else
properties
.
last_irreversible_block_num
end
# First pass replays latest a random number of blocks to test chunking.
first_block_num
||=
current_block_num
-
(
rand
*
200
).
to_i
stream
.
operations
(
at_block_num:
first_block_num
,
include_virtual:
true
)
do
|
op
,
trx_id
,
block_num
|
puts
"
#{
block_num
}
::
#{
trx_id
}
; op:
#{
op
.
type
}
"
end
end
end
end
end
end
...
...
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