Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
297
Merge Requests
42
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
f64d1050
Commit
f64d1050
authored
18 minutes ago
by
Emiliano Balbuena
Browse files
Options
Download
(test): WithdrawEvent spec test
parent
ce560990
goal/withdrawals-approval
1 merge request
!393
(feat): Withdrawal status support
Pipeline
#95695461
failed with stages
in 2 minutes and 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
17 deletions
+42
-17
Spec/Core/Blockchain/Events/WithdrawEventSpec.php
View file @
f64d1050
...
...
@@ -6,6 +6,7 @@ use Minds\Core\Blockchain\Transactions\Repository;
use
Minds\Core\Blockchain\Transactions\Transaction
;
use
Minds\Core\Config\Config
;
use
Minds\Core\Rewards\Withdraw\Manager
;
use
Minds\Core\Rewards\Withdraw\Request
;
use
Minds\Core\Util\BigNumber
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
...
...
@@ -31,9 +32,9 @@ class WithdrawEventSpec extends ObjectBehavior
->
willReturn
([
'contracts'
=>
[
'withdraw'
=>
[
'contract_address'
=>
'0xasd'
]
]
'contract_address'
=>
'0xasd'
,
]
,
]
,
]);
}
...
...
@@ -46,30 +47,54 @@ class WithdrawEventSpec extends ObjectBehavior
{
$this
->
getTopics
()
->
shouldReturn
([
'0x317c0f5ab60805d3e3fb6aaa61ccb77253bbb20deccbbe49c544de4baa4d7f8f'
,
'blockchain:fail'
'blockchain:fail'
,
]);
}
public
function
it_should_complete_withdrawal_on_event
()
public
function
it_should_complete_withdrawal_on_event
(
Request
$request
,
Transaction
$transaction
)
{
$this
->
manager
->
complete
(
Argument
::
that
(
function
(
$request
)
{
return
$request
->
getTx
()
==
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
&&
$request
->
getAddress
()
==
'0x177fd9efd24535e73b81e99e7f838cdef265e6cb'
&&
$request
->
getUserGuid
()
==
(
string
)
BigNumber
::
_
(
'786645648014315523'
)
&&
$request
->
getGas
()
==
(
string
)
BigNumber
::
_
(
'67839000000000'
)
&&
$request
->
getAmount
()
==
(
string
)
BigNumber
::
_
(
'10000000000000000000'
);
}),
Argument
::
type
(
'\Minds\Core\Blockchain\Transactions\Transaction'
))
$transaction
->
getTimestamp
()
->
shouldBeCalled
()
->
willReturn
(
123456789
);
$request
->
getAddress
()
->
shouldBeCalled
()
->
willReturn
(
'0x177fd9efd24535e73b81e99e7f838cdef265e6cb'
);
$request
->
getGas
()
->
shouldBeCalled
()
->
willReturn
(
'67839000000000'
);
$request
->
getAmount
()
->
shouldBeCalled
()
->
willReturn
(
'10000000000000000000'
);
$this
->
manager
->
get
(
Argument
::
that
(
function
(
Request
$request
)
{
return
(
string
)
$request
->
getUserGuid
()
===
'786645648014315523'
&&
$request
->
getTimestamp
()
===
123456789
&&
$request
->
getTx
()
===
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
;
})
)
->
shouldBeCalled
()
->
willReturn
(
$request
);
$this
->
manager
->
confirm
(
$request
,
Argument
::
type
(
'\Minds\Core\Blockchain\Transactions\Transaction'
))
->
shouldBeCalled
();
$data
=
"0x000000000000000000000000177fd9efd24535e73b81e99e7f838cdef265e6cb"
.
"0000000000000000000000000000000000000000000000000aeaba0c8e001003"
.
"00000000000000000000000000000000000000000000000000003db2ff7f3600"
.
"0000000000000000000000000000000000000000000000008ac7230489e80000"
;
$this
->
onRequest
([
'address'
=>
'0xasd'
,
'data'
=>
$data
,
'transactionHash'
=>
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
],
new
T
ransaction
);
'transactionHash'
=>
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
,
],
$t
ransaction
);
}
public
function
it_should_send_a_blockchain_fail_event
(
Transaction
$transaction
)
...
...
@@ -115,8 +140,8 @@ class WithdrawEventSpec extends ObjectBehavior
'contracts'
=>
[
'withdraw'
=>
[
'contract_address'
=>
'0x277fd9efd24535e73b81e99e7f838cdef265e6cb'
,
]
]
]
,
]
,
]);
$data
=
"0x000000000000000000000000177fd9efd24535e73b81e99e7f838cdef265e6cb"
...
...
@@ -127,7 +152,7 @@ class WithdrawEventSpec extends ObjectBehavior
->
duringOnRequest
([
'address'
=>
'0x177fd9efd24535e73b81e99e7f838cdef265e6cb'
,
'data'
=>
$data
,
'transactionHash'
=>
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
'transactionHash'
=>
'0x62a70ccf3b37b9368efa3dd4785e715139c994ba9957a125e299b14a8eccd00c'
,
],
(
new
Transaction
())
->
setContract
(
'withdraw'
));
}
}
This diff is collapsed.
Please
register
or
sign in
to comment