Skip to content

Commit

Permalink
revert tune selftest speed
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Dec 8, 2020
1 parent a701b76 commit 36d8701
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions test/selftest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,9 @@ public function finish()
if( file_exists( __DIR__ . '/private.php' ) )
require_once __DIR__ . '/private.php';

function selftest_ensure( $wk, $tx, $confirmations, $sleep )
{
$tx = $wk->ensure( $tx, $confirmations, $sleep );
if( $tx === false )
return false;

// testnet workaround
sleep( 20 );
return $tx;
}

$wavesAmount = 1000000000;
$confirmations = 0;
$sleep = 1;
$confirmations = 1;
$sleep = 10;
$nodes =
[
'https://example.com',
Expand Down Expand Up @@ -301,7 +290,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wkFaucet->txTransfer( $wk->getAddress(), $wavesAmount );
$tx = $wkFaucet->txSign( $tx );
$tx = $wkFaucet->txBroadcast( $tx );
$tx = selftest_ensure( $wkFaucet, $tx, $confirmations, $sleep );
$tx = $wkFaucet->ensure( $tx, $confirmations, $sleep );

$balance = $wk->balance();
$balance = $balance[0]['balance'];
Expand All @@ -319,7 +308,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txIssue( $tokenName, $tokenDescription, $tokenQuantity, $tokenDecimals, true );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$tokenId = $tx['id'];
$balance = $wk->balance();
Expand All @@ -333,7 +322,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txReissue( $tokenId, $tokenQuantity, false );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$balance = $wk->balance();
$balance = $balance[$tokenId]['balance'];
Expand All @@ -357,7 +346,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txBurn( $tokenId, $tokenQuantity );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$balance = $wk->balance();
$balance = $balance[$tokenId]['balance'];
Expand All @@ -370,7 +359,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txSponsorship( $tokenId, 1 );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$balance = $wk->balance();
$balance = $balance[0]['balance'];
Expand All @@ -379,7 +368,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txTransfer( $wkFaucet->getAddress(), 1, $tokenId, $options );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$balanceNew = $wk->balance();
$balanceNew = $balanceNew[0]['balance'];
Expand All @@ -396,7 +385,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txLease( $wkFaucet->getAddress(), $leaseAmount );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$leaseId = $tx['id'];

Expand All @@ -411,7 +400,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txLeaseCancel( $leaseId );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, 0, $sleep );
$tx = $wk->ensure( $tx, 0, $sleep );

$t->test( $tx !== false && $leasedTransfer === false );
}
Expand All @@ -422,7 +411,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txAlias( $alias );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$address = $wk->getAddressByAlias( $alias );

Expand All @@ -445,7 +434,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txMass( $recipients, $amounts, $tokenId );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$balancesOK = true;
for( $i = 0; $i < $n; $i++ )
Expand Down Expand Up @@ -489,7 +478,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txData( $data );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$dataOK = true;
foreach( $data as $key => $value )
Expand Down Expand Up @@ -517,15 +506,15 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txAddressScript( $script['script'] );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$scriptOK = $script['script'] === $wk->getAddressScript()['script'];

$tx = $wk->txAddressScript( null );
$tx['fee'] = $wk->calculateFee( $tx );
$tx = $wkFaucet->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$t->test( $scriptOK && $tx !== false );
}
Expand All @@ -539,7 +528,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txIssue( $tokenName, $tokenDescription, $tokenQuantity, $tokenDecimals, true, $script );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$tokenId = $tx['id'];
$balance = $wk->balance();
Expand All @@ -550,7 +539,7 @@ function selftest_ensure( $wk, $tx, $confirmations, $sleep )
$tx = $wk->txAssetScript( $tokenId, $script );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = selftest_ensure( $wk, $tx, $confirmations, $sleep );
$tx = $wk->ensure( $tx, $confirmations, $sleep );

$tx = $wk->txReissue( $tokenId, $tokenQuantity, false );
$tx = $wk->txSign( $tx );
Expand Down

0 comments on commit 36d8701

Please sign in to comment.