public function testSatoshiConversion() { $toSatoshi = [["0.00000001", "1", 1], [1.0E-8, "1", 1], ["0.29560000", "29560000", 29560000], [0.2956, "29560000", 29560000], ["1.0000009", "100000090", 100000090], [1.0000009, "100000090", 100000090], ["1.00000009", "100000009", 100000009], [1.00000009, "100000009", 100000009], ["21000000.00000001", "2100000000000001", 2100000000000001], [21000000.00000001, "2100000000000001", 2100000000000001], ["21000000.0000009", "2100000000000090", 2100000000000090], [21000000.0000009, "2100000000000090", 2100000000000090], ["21000000.00000009", "2100000000000009", 2100000000000009], [21000000.00000009, "2100000000000009", 2100000000000009], ["210000000.00000009", "21000000000000009", 21000000000000009], [210000000.0000001, "21000000000000009", 21000000000000009]]; $toBTC = [["1", "0.00000001"], [1, "0.00000001"], ["29560000", "0.29560000"], [29560000, "0.29560000"], ["100000090", "1.00000090"], [100000090, "1.00000090"], ["100000009", "1.00000009"], [100000009, "1.00000009"], ["2100000000000001", "21000000.00000001"], [2100000000000001, "21000000.00000001"], ["2100000000000090", "21000000.00000090"], [2100000000000090, "21000000.00000090"], ["2100000000000009", "21000000.00000009"], [2100000000000009, "21000000.00000009"], ["21000000000000009", "210000000.00000009"], [21000000000000009, "210000000.00000009"], ["210000000000000009", "2100000000.00000009"], [210000000000000009, "2100000000.00000009"], ["2100000000000000009", "21000000000.00000009"], [2100000000000000009, "21000000000.00000009"]]; foreach ($toSatoshi as $i => $test) { $btc = $test[0]; $satoshiString = $test[1]; $satoshiInt = $test[2]; $string = BitcoinLib::toSatoshiString($btc); $this->assertEquals($satoshiString, $string, "[{$i}] {$btc} => {$satoshiString} =? {$string}"); $this->assertTrue($satoshiString === $string, "[{$i}] {$btc} => {$satoshiString} ==? {$string}"); $int = BitcoinLib::toSatoshi($btc); $this->assertEquals($satoshiInt, $int, "[{$i}] {$btc} => {$satoshiInt} =? {$int}"); $this->assertTrue($satoshiInt === $int, "[{$i}] {$btc} => {$satoshiInt} ==? {$int}"); } foreach ($toBTC as $i => $test) { $satoshi = $test[0]; $btc = $test[1]; $this->assertEquals($btc, BitcoinLib::toBTC($satoshi), "[{$i}] {$satoshi} => {$btc}"); $this->assertTrue($btc === BitcoinLib::toBTC($satoshi), "[{$i}] {$satoshi} => {$btc}"); } }