vdk bitstring testing
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
-module(bits).
|
||||
|
||||
-compile([export_all, nowarn_export_all]).
|
||||
|
||||
|
||||
empty() ->
|
||||
<<>>.
|
||||
|
||||
rand_bit() ->
|
||||
case rand:uniform(2) of
|
||||
1 -> <<0:1>>;
|
||||
2 -> <<1:1>>
|
||||
end.
|
||||
|
||||
rand_bits(N) when N =< 8 ->
|
||||
<<Foo:N, _/bits>> = rand:bytes(1),
|
||||
<<Foo:N>>.
|
||||
rand_bits(N) when N > 8 ->
|
||||
Num_Bytes = N div 8,
|
||||
Num_Trailing_Bits = N rem 8,
|
||||
<<( rand_bits(Num_Trailing_Bits) )/bits,
|
||||
( rand:bytes(Num_Bytes) )/binary>>.
|
||||
|
||||
@@ -27,10 +27,6 @@
|
||||
<h5>Failed case log:</h5>
|
||||
<pre id="rlp-assershins"></pre>
|
||||
|
||||
<h1>Tx Decoding</h1>
|
||||
<input style="width: 800px;" type="text" id="tx-stuff" value="tx_+FgMAaEByWN+RgDnqzvC5n/GQOgjdkRE9DBV2l1VeKSaN1r6GNyhAXtm5sMFBwg25Ol5IFI9w+pZy7/YbFi6BwPqi80KuKdsCoYPJvVhyAAACYdoYWluYW5hA7ZC1w=="></input>
|
||||
<button id="tx-go">Go!</button>
|
||||
|
||||
|
||||
<script type="module" src="dist/test.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as cases from './jex_include/local-vanillae_test_cases-0.1.0/dist/cases
|
||||
import * as b64 from './jex_include/local-vanillae-0.1.0/dist/b64.js';
|
||||
import * as b58 from './jex_include/local-vanillae-0.1.0/dist/b58.js';
|
||||
import * as rlp from './jex_include/local-vanillae-0.1.0/dist/rlp.js';
|
||||
import * as ser from './jex_include/local-vanillae-0.1.0/dist/ser.js';
|
||||
|
||||
|
||||
// TODO: move this to rlp library
|
||||
@@ -201,12 +200,6 @@ function rlp_tests(): void {
|
||||
}
|
||||
|
||||
|
||||
function tx_tests(): void {
|
||||
// @ts-ignore value exists
|
||||
let tx_stuff = document.getElementById('tx-stuff')!.value;
|
||||
console.log(ser.decode_tx(tx_stuff));
|
||||
}
|
||||
|
||||
|
||||
function main(): void {
|
||||
document.getElementById('b64-total-cases')!.innerHTML = '' + cases.base64.length;
|
||||
@@ -217,8 +210,6 @@ function main(): void {
|
||||
|
||||
document.getElementById('rlp-total-cases')!.innerHTML = '' + cases.rlp.length;
|
||||
document.getElementById('rlp-go')!.onclick = rlp_tests;
|
||||
|
||||
document.getElementById('tx-go')!.onclick = tx_tests;
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user