Add AddressFormatter test.
This commit is contained in:
parent
297db091f7
commit
76c54335d6
@ -37,8 +37,8 @@ class AddressFormatter implements IFormatter
|
|||||||
}
|
}
|
||||||
return '0x' . $value;
|
return '0x' . $value;
|
||||||
}
|
}
|
||||||
$value = IntegerFormatter::format($value);
|
$value = IntegerFormatter::format($value, 40);
|
||||||
|
|
||||||
return $value;
|
return '0x' . $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,15 +35,21 @@ class AddressFormatterTest extends TestCase
|
|||||||
$formatter = $this->formatter;
|
$formatter = $this->formatter;
|
||||||
|
|
||||||
$address = $formatter->format('0Xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
$address = $formatter->format('0Xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
||||||
|
|
||||||
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
||||||
|
|
||||||
$address = $formatter->format('0XCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
|
$address = $formatter->format('0XCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
|
||||||
|
|
||||||
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
||||||
|
|
||||||
$address = $formatter->format('0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
|
$address = $formatter->format('0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
|
||||||
|
|
||||||
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
||||||
|
|
||||||
|
$address = $formatter->format('CA35B7D915458EF540ADE6068DFE2F44E8FA733C');
|
||||||
|
$this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
|
||||||
|
|
||||||
|
$address = $formatter->format('1234');
|
||||||
|
$this->assertEquals($address, '0x00000000000000000000000000000000000004d2');
|
||||||
|
|
||||||
|
$address = $formatter->format('abcd');
|
||||||
|
$this->assertEquals($address, '0x000000000000000000000000000000000000abcd');
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user