Skip to content

Commit

Permalink
Update ganache for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Sep 4, 2023
1 parent 588d5b8 commit 88e8bab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y nodejs
sudo npm install -g ganache-cli
sudo npm install -g ganache
- uses: actions/checkout@v2

Expand Down
8 changes: 4 additions & 4 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash

ganache-cli -g 0 -l 6000000 > /dev/null &
ganachecli_pid=$!
echo "Start ganache-cli pid: $ganachecli_pid and sleep 3 seconds"
ganache -g 0 -l 6000000 --wallet.seed test,test,test,test,test,test,test,test,test,test,test,test --miner.coinbase 0x4DABDacE120050c79E355A5Ba99047B955f37fFc > /dev/null &
ganache_pid=$!
echo "Start ganache pid: $ganache_pid and sleep 3 seconds"

sleep 3

vendor/bin/phpunit --coverage-clover=coverage.xml
ret=$?

kill -9 $ganachecli_pid
kill -9 $ganache_pid
echo "Kill ganache-cli"

exit $ret
17 changes: 8 additions & 9 deletions test/unit/EthApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function testSendRawTransaction()

$eth->sendRawTransaction('0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', function ($err, $transaction) {
if ($err !== null) {
return $this->assertEquals('invalid remainder', $err->getMessage());
return $this->assertStringContainsString('invalid remainder', $err->getMessage());
}
$this->assertTrue(is_string($transaction));
});
Expand Down Expand Up @@ -420,7 +420,7 @@ public function testGetBlockByHash()
if ($err !== null) {
return $this->assertEquals('Key not found in database', $err->getMessage());
}
$this->assertTrue($block !== null);
$this->assertTrue($block === null);
});
}

Expand Down Expand Up @@ -489,7 +489,7 @@ public function testGetTransactionByBlockNumberAndIndex()
if ($err !== null) {
return $this->assertStringStartsWith('LevelUpArrayAdapter named \'blocks\' index out of range', $err->getMessage());
}
$this->assertTrue($transaction !== null);
$this->assertTrue($transaction === null);
});
}

Expand Down Expand Up @@ -523,7 +523,7 @@ public function testGetUncleByBlockHashAndIndex()
if ($err !== null) {
return $this->fail($err->getMessage());
}
$this->assertTrue($uncle !== null);
$this->assertTrue($uncle === null);
});
}

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

Expand Down Expand Up @@ -632,8 +632,7 @@ public function testGetFilterChanges()

$eth->getFilterChanges('0x01', function ($err, $changes) {
if ($err !== null) {
// infura banned us to get filter changes
return $this->fail($err->getMessage());
return $this->assertEquals('filter not found', $err->getMessage());
}
$this->assertTrue(is_array($changes));
});
Expand All @@ -650,8 +649,7 @@ public function testGetFilterLogs()

$eth->getFilterLogs('0x01', function ($err, $logs) {
if ($err !== null) {
// infura banned us to get filter logs
return $this->fail($err->getMessage());
return $this->assertEquals('filter not found', $err->getMessage());
}
$this->assertTrue(is_array($logs));
});
Expand Down Expand Up @@ -733,6 +731,7 @@ public function testFeeHistory()
if ($err !== null) {
return $this->fail($err->getMessage());
}
var_dump($feeHistory);
});
}

Expand Down
5 changes: 4 additions & 1 deletion test/unit/PersonalApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ public function testSendTransaction()
return $this->fail($err->getMessage());
}
$this->newAccount = $account;
var_dump($account);
$this->assertTrue(is_string($account));
});

$this->web3->eth->sendTransaction([
'from' => $this->coinbase,
'to' => $this->newAccount,
'value' => '0xfffffffff',
'value' => '0xfffffffffffff',
], function ($err, $transaction) {
if ($err !== null) {
return $this->fail($err->getMessage());
Expand All @@ -188,6 +189,8 @@ public function testSendTransaction()
'from' => $this->newAccount,
'to' => $this->coinbase,
'value' => '0x01',
'gasLimit' => 21000,
'gasPrice' => 5000000000,
], '123456', function ($err, $transaction) {
if ($err !== null) {
return $this->fail($err->getMessage());
Expand Down

0 comments on commit 88e8bab

Please sign in to comment.