Skip to content

Instantly share code, notes, and snippets.

@panprog
Created July 18, 2022 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panprog/32adefdc853ccd0fd0f1aad85c526bea to your computer and use it in GitHub Desktop.
Save panprog/32adefdc853ccd0fd0f1aad85c526bea to your computer and use it in GitHub Desktop.
ENS BytesUtil and RRUtils PoC
diff --git a/test/dnssec-oracle/TestBytesUtils.sol b/test/dnssec-oracle/TestBytesUtils.sol
index af92c63..53b6bdb 100644
--- a/test/dnssec-oracle/TestBytesUtils.sol
+++ b/test/dnssec-oracle/TestBytesUtils.sol
@@ -24,6 +24,9 @@ contract TestBytesUtils {
require("xax".compare(1, 1, "xxbxx", 2, 1) < 0 == true, "Compare same length");
require("xax".compare(1, 1, "xxabxx", 2, 2) < 0 == true, "Compare different length");
require("xax".compare(1, 1, "xxaxx", 2, 1) == 0 == true, "Compare same with different offset");
+ require("01234567890123450123456789012345ab".compare(0, 33, "01234567890123450123456789012345aa", 0, 33) == 0 == true, "Compare different long strings same length smaller partial length which must be equal");
+ require("01234567890123450123456789012345ab".compare(0, 33, "01234567890123450123456789012345aa", 0, 34) < 0 == true, "Compare long strings same length different partial length");
+ require("0123456789012345012345678901234a".compare(0, 32, "0123456789012345012345678901234b", 0, 32) < 0 == true, "Compare strings exactly 32 characters long");
}
function testCompare() public pure {
diff --git a/test/dnssec-oracle/TestRRUtils.sol b/test/dnssec-oracle/TestRRUtils.sol
index 52a0769..eebe288 100644
--- a/test/dnssec-oracle/TestRRUtils.sol
+++ b/test/dnssec-oracle/TestRRUtils.sol
@@ -58,6 +58,9 @@ contract TestRRUtils {
bytes memory b_a_c = hex'01620161016300';
bytes memory ab_c_d = hex'0261620163016400';
bytes memory a_c_d = hex'01610163016400';
+
+ bytes memory verylong1_eth = hex'223031323334353637383930313233343536373839303132333435363738393031613031303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637380365746800';
+ bytes memory verylong2_eth = hex'2130313233343536373839303132333435363738393031323334353637383930316131303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637380365746800';
require(hex'0301616100'.compareNames(hex'0302616200') < 0, "label lengths are correctly checked");
require(a_b_c.compareNames(c) > 0, "one name has a difference of >1 label to with the same root name");
@@ -71,6 +74,8 @@ contract TestRRUtils {
require(bthLabXyz.compareNames(bthLabXyz) == 0, "bthLab.xyz and bthLab.xyz are the same");
require(ethLabXyz.compareNames(bthLabXyz) > 0, "ethLab.xyz comes after bethLab.xyz");
require(bthLabXyz.compareNames(xyz) > 0, "bthLab.xyz comes after xyz");
+
+ require(verylong1_eth.compareNames(verylong2_eth) > 0, "longa.vlong.eth comes after long.vlong.eth");
}
function testSerialNumberGt() public pure {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment