mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Change from testing arrays to BitSet objects directly
This commit is contained in:
parent
c15a742ffa
commit
3c371a543f
@ -18,6 +18,7 @@ package org.bitcoinj.core;
|
|||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -43,26 +44,26 @@ public class AltcoinBlockTest {
|
|||||||
public void testGetVersionFlags() {
|
public void testGetVersionFlags() {
|
||||||
AltcoinBlock block = new AltcoinBlock(params, 0L);
|
AltcoinBlock block = new AltcoinBlock(params, 0L);
|
||||||
BitSet expected = new BitSet(8);
|
BitSet expected = new BitSet(8);
|
||||||
assertArrayEquals(block.getVersionFlags().toByteArray(), expected.toByteArray());
|
assertEquals(block.getVersionFlags(), expected);
|
||||||
|
|
||||||
// Set everything but the version flags
|
// Set everything but the version flags
|
||||||
block = new AltcoinBlock(params, 0xffff00ff);
|
block = new AltcoinBlock(params, 0xffff00ff);
|
||||||
assertArrayEquals(block.getVersionFlags().toByteArray(), expected.toByteArray());
|
assertEquals(block.getVersionFlags(), expected);
|
||||||
|
|
||||||
// Set everything
|
// Set everything
|
||||||
block = new AltcoinBlock(params, 0xffffffff);
|
block = new AltcoinBlock(params, 0xffffffff);
|
||||||
expected.set(0, 8);
|
expected.set(0, 8);
|
||||||
assertArrayEquals(block.getVersionFlags().toByteArray(), expected.toByteArray());
|
assertEquals(block.getVersionFlags(), expected);
|
||||||
|
|
||||||
// Set only the version flags
|
// Set only the version flags
|
||||||
block = new AltcoinBlock(params, 0x0000ff00);
|
block = new AltcoinBlock(params, 0x0000ff00);
|
||||||
assertArrayEquals(block.getVersionFlags().toByteArray(), expected.toByteArray());
|
assertEquals(block.getVersionFlags(), expected);
|
||||||
|
|
||||||
// Set some of the version flags
|
// Set some of the version flags
|
||||||
block = new AltcoinBlock(params, 0x00001700);
|
block = new AltcoinBlock(params, 0x00001700);
|
||||||
expected.clear(0, 8);
|
expected.clear(0, 8);
|
||||||
expected.set(0, 3);
|
expected.set(0, 3);
|
||||||
expected.set(4);
|
expected.set(4);
|
||||||
assertArrayEquals(block.getVersionFlags().toByteArray(), expected.toByteArray());
|
assertEquals(block.getVersionFlags(), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user