Skip to content

Commit

Permalink
Update message when test failed
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Aug 27, 2023
1 parent 901e247 commit af62a08
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion test/unit/ContractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ public function testEstimateGas()
], function ($err, $result) use ($contract) {
if ($err !== null) {
// infura api gg
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
if (isset($result)) {
echo "\nEstimate gas: " . $result->toString() . "\n";
Expand Down
66 changes: 33 additions & 33 deletions test/unit/EthApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function testGetBlockTransactionCountByHash()

$eth->getBlockTransactionCountByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transactionCount) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_numeric($transactionCount->toString()));
});
Expand All @@ -244,7 +244,7 @@ public function testGetBlockTransactionCountByNumber()

$eth->getBlockTransactionCountByNumber('0x0', function ($err, $transactionCount) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_numeric($transactionCount->toString()));
});
Expand All @@ -261,7 +261,7 @@ public function testGetUncleCountByBlockHash()

$eth->getUncleCountByBlockHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $uncleCount) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_numeric($uncleCount->toString()));
});
Expand All @@ -278,7 +278,7 @@ public function testGetUncleCountByBlockNumber()

$eth->getUncleCountByBlockNumber('0x0', function ($err, $uncleCount) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_numeric($uncleCount->toString()));
});
Expand All @@ -295,7 +295,7 @@ public function testGetCode()

$eth->getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', function ($err, $code) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($code));
});
Expand All @@ -313,7 +313,7 @@ public function testSign()
$eth->sign('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0xdeadbeaf', function ($err, $sign) {
if ($err !== null) {
// infura banned us to sign message
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($sign));
});
Expand All @@ -338,7 +338,7 @@ public function testSendTransaction()
], function ($err, $transaction) {
if ($err !== null) {
// infura banned us to send transaction
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($transaction));
});
Expand All @@ -355,7 +355,7 @@ public function testSendRawTransaction()

$eth->sendRawTransaction('0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($transaction));
});
Expand All @@ -379,7 +379,7 @@ public function testCall()
'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
], function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($transaction));
});
Expand All @@ -403,7 +403,7 @@ public function testEstimateGas()
'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
], function ($err, $gas) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_numeric($gas->toString()));
});
Expand All @@ -420,7 +420,7 @@ public function testGetBlockByHash()

$eth->getBlockByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', false, function ($err, $block) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($block !== null);
});
Expand All @@ -437,7 +437,7 @@ public function testGetBlockByNumber()

$eth->getBlockByNumber('latest', false, function ($err, $block) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
// weird behavior, see https://github.com/web3p/web3.php/issues/16
$this->assertTrue($block !== null);
Expand All @@ -455,7 +455,7 @@ public function testGetTransactionByHash()

$eth->getTransactionByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($transaction == null);
});
Expand All @@ -472,7 +472,7 @@ public function testGetTransactionByBlockHashAndIndex()

$eth->getTransactionByBlockHashAndIndex('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', '0x0', function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($transaction == null);
});
Expand All @@ -489,7 +489,7 @@ public function testGetTransactionByBlockNumberAndIndex()

$eth->getTransactionByBlockNumberAndIndex('0xe8', '0x0', function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($transaction !== null);
});
Expand All @@ -506,7 +506,7 @@ public function testGetTransactionReceipt()

$eth->getTransactionReceipt('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transaction) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($transaction == null);
});
Expand All @@ -523,7 +523,7 @@ public function testGetUncleByBlockHashAndIndex()

$eth->getUncleByBlockHashAndIndex('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', '0x0', function ($err, $uncle) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($uncle !== null);
});
Expand All @@ -540,7 +540,7 @@ public function testGetUncleByBlockNumberAndIndex()

$eth->getUncleByBlockNumberAndIndex('0xe8', '0x0', function ($err, $uncle) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue($uncle !== null);
});
Expand All @@ -557,7 +557,7 @@ public function testCompileSolidity()

$eth->compileSolidity('contract test { function multiply(uint a) returns(uint d) { return a * 7; } }', function ($err, $compiled) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($compiled));
});
Expand All @@ -574,7 +574,7 @@ public function testCompileLLL()

$eth->compileLLL('(returnlll (suicide (caller)))', function ($err, $compiled) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($compiled));
});
Expand All @@ -591,7 +591,7 @@ public function testCompileSerpent()

$eth->compileSerpent('\/* some serpent *\/', function ($err, $compiled) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($compiled));
});
Expand All @@ -614,7 +614,7 @@ public function testNewFilter()
], function ($err, $filter) {
if ($err !== null) {
// infura banned us to new filter
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($filter));
});
Expand All @@ -632,7 +632,7 @@ public function testNewBlockFilter()
$eth->newBlockFilter(function ($err, $filter) {
if ($err !== null) {
// infura banned us to new block filter
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($filter));
});
Expand All @@ -650,7 +650,7 @@ public function testNewPendingTransactionFilter()
$eth->newPendingTransactionFilter(function ($err, $filter) {
if ($err !== null) {
// infura banned us to new pending transaction filter
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($filter));
});
Expand All @@ -668,7 +668,7 @@ public function testUninstallFilter()
$eth->uninstallFilter('0x01', function ($err, $filter) {
if ($err !== null) {
// infura banned us to uninstall filter
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_bool($filter));
});
Expand All @@ -686,7 +686,7 @@ public function testGetFilterChanges()
$eth->getFilterChanges('0x01', function ($err, $changes) {
if ($err !== null) {
// infura banned us to get filter changes
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_array($changes));
});
Expand All @@ -704,7 +704,7 @@ public function testGetFilterLogs()
$eth->getFilterLogs('0x01', function ($err, $logs) {
if ($err !== null) {
// infura banned us to get filter logs
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_array($logs));
});
Expand All @@ -726,7 +726,7 @@ public function testGetLogs()
'topics' => ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', null, ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc']]
], function ($err, $logs) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_array($logs));
});
Expand All @@ -743,7 +743,7 @@ public function testGetWork()

$eth->getWork(function ($err, $work) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_array($work));
});
Expand All @@ -764,7 +764,7 @@ public function testSubmitWork()
'0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000'
, function ($err, $work) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_bool($work));
});
Expand All @@ -784,7 +784,7 @@ public function testSubmitHashrate()
'0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000'
, function ($err, $work) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_bool($work));
});
Expand All @@ -803,7 +803,7 @@ public function testGetBlockByNumberAsync()
// should return reactphp promise
$promise = $eth->getBlockByNumber('latest', false, function ($err, $block) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
// weird behavior, see https://github.com/web3p/web3.php/issues/16
$this->assertTrue($block !== null);
Expand All @@ -825,7 +825,7 @@ public function testUnallowedMethod()

$eth->hello(function ($err, $hello) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(true);
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/EthBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testBatch()

$eth->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->fail('Got error!');
return $this->fail($err->getMessage());
}
$this->assertTrue($data[0] instanceof BigNumber);
$this->assertTrue($data[1] !== null);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/NetBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testBatch()

$net->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->fail('Got error!');
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($data[0]));
$this->assertTrue(is_bool($data[1]));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/PersonalBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testBatch()

$personal->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->assertTrue($err !== null);
return $this->fail($err->getMessage());
}
$this->assertTrue(is_array($data[0]));
$this->assertTrue(is_string($data[1]));
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ShhBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testBatch()

$shh->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->fail('Got error!');
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($data[0]));
$this->assertTrue(is_string($data[1]));
Expand All @@ -65,7 +65,7 @@ public function testBatch()

// $shh->provider->execute(function ($err, $data) {
// if ($err !== null) {
// return $this->fail('Got error!');
// return $this->fail($err->getMessage());
// }
// $this->assertTrue(is_string($data[0]));
// $this->assertFalse($data[1]);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Web3BatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testBatch()

$web3->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->fail('Got error!');
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($data[0]));
$this->assertEquals($data[1], $this->testHash);
Expand All @@ -72,7 +72,7 @@ public function testWrongParam()

$web3->provider->execute(function ($err, $data) {
if ($err !== null) {
return $this->fail('Got error!');
return $this->fail($err->getMessage());
}
$this->assertTrue(is_string($data[0]));
$this->assertEquals($data[1], $this->testHash);
Expand Down

0 comments on commit af62a08

Please sign in to comment.