Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions evm/src/test/java/org/hyperledger/besu/evm/UInt256Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,21 @@ public void mulMod() {
}
}

@Test
public void uint512IsUInt64() {
// All high limbs zero — fits in 64 bits
var fitsIn64 = new UInt256.UInt512(0, 0, 0, 0, 0, 0, 0, 42);
assertThat(fitsIn64.isUInt64()).as("all high limbs zero").isTrue();

// u7=1, u6=2: AND gives 0 but OR gives 3 — does NOT fit in 64 bits
var andMasksToZero = new UInt256.UInt512(1, 2, 0, 0, 0, 0, 0, 42);
assertThat(andMasksToZero.isUInt64()).as("u7=1,u6=2 should not fit in 64 bits").isFalse();

// Only u1 is non-zero — does NOT fit in 64 bits
var singleHighLimb = new UInt256.UInt512(0, 0, 0, 0, 0, 0, 1, 42);
assertThat(singleHighLimb.isUInt64()).as("u1=1 should not fit in 64 bits").isFalse();
}

@Test
public void signedMod() {
final Random random = new Random(432);
Expand Down