Skip to content

Commit ac795e2

Browse files
committed
dgb: wire src/impl/dgb/test share fixtures (oracle consensus-identity guard)
Enable add_subdirectory(test) and add dgb_share_test, mirroring the ltc/btc test pattern. The test links the dgb OBJECT lib (pool/share TU) into a gtest executable, build-verifying the Phase-B pool/share stack, and asserts the DGB-oracle-conformed (frstrtr/p2pool-dgb-scrypt) consensus + sharechain-identity params adjudicated at prescan-DGB: - IDENTIFIER 4b62545b1a631afe / PREFIX 1c0553f23ebfcffe (isolation primitives — must stay byte-exact per coin) - SEGWIT_ACTIVATION_VERSION 35, P2P_PORT 5024, proto floor 1700 / advertised 3301, SHARE_PERIOD 15, CHAIN_LENGTH 2880 - v35 donation = forrestv P2PK (4104ffd0..ac, 67B); v36 = combined P2SH (23B) via get_donation_script() version switch - ADDRESS_VERSION 0x1e (D) / ADDRESS_P2SH_VERSION 0x3f (S) Locks the conformance landed in the stack against silent regression. Local build EXIT=0; dgb_share_test 5/5 PASS. Non-stacking lane off stack tip; captured-block PoW + multi-algo accept-by-continuity fixtures are a follow-up (see test/README.txt).
1 parent 10a5b5b commit ac795e2

3 files changed

Lines changed: 89 additions & 1 deletion

File tree

src/impl/dgb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if(COIN_DGB)
2020
message(STATUS "c2pool: DGB Scrypt-only coin module enabled")
2121
add_subdirectory(coin)
2222
# add_subdirectory(daemon)
23-
# add_subdirectory(test)
23+
add_subdirectory(test)
2424

2525
# dgb -- DGB Scrypt pool-layer OBJECT lib. Mirrors the ltc OBJECT lib
2626
# (src/impl/ltc/CMakeLists.txt): compiles the real NodeImpl translation unit

src/impl/dgb/test/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# DGB module tests. Mirrors src/impl/ltc/test/CMakeLists.txt — links the dgb
2+
# OBJECT lib (pool/share TU) so the share codec + consensus params are build-
3+
# verified into a test executable. Gated on BUILD_TESTING + GTest like the
4+
# sibling coins; registered via gtest_add_tests for the CI --target allowlist.
5+
if (BUILD_TESTING AND GTest_FOUND)
6+
add_executable(dgb_share_test share_test.cpp)
7+
target_link_libraries(dgb_share_test PRIVATE
8+
GTest::gtest_main GTest::gtest
9+
core dgb
10+
)
11+
# OBJECT-lib SCC direct-naming (#22/#39) — mirror the ltc test link set.
12+
target_link_libraries(dgb_share_test PRIVATE
13+
c2pool_payout c2pool_merged_mining c2pool_hashrate c2pool_storage
14+
dgb_coin pool sharechain)
15+
16+
include(GoogleTest)
17+
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
18+
gtest_add_tests(dgb_share_test "" AUTO)
19+
endif()

src/impl/dgb/test/share_test.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// DGB Scrypt-only coin module — share / consensus-identity fixtures (M3).
2+
// Mirrors src/impl/btc/test + src/impl/ltc/test. Locks the oracle-conformed
3+
// consensus + sharechain-identity params against frstrtr/p2pool-dgb-scrypt
4+
// (IDENTIFIER 4B62545B1A631AFE, PREFIX 1c0553f23ebfcffe). These are the params
5+
// adjudicated CONFORM at prescan-DGB (#131/#137/#141); this guards regressions.
6+
//
7+
// SCOPE (project_v36_dgb_scrypt_only): V36 validates SCRYPT shares only.
8+
// Scrypt-family wire format mirrors LTC; DGB-net identity lives in the params
9+
// asserted below, NOT in the share codec. Captured-block PoW fixtures + multi-
10+
// algo accept-by-continuity vectors are a follow-up slice (see README.txt).
11+
12+
#include <gtest/gtest.h>
13+
14+
#include <impl/dgb/config_pool.hpp>
15+
#include <impl/dgb/config_coin.hpp>
16+
#include <impl/dgb/share.hpp>
17+
18+
// Sharechain-identity: the isolation primitives (PREFIX / IDENTIFIER) are the
19+
// per-coin namespacing boundary — they MUST stay byte-exact to the DGB oracle.
20+
TEST(DGB_share_test, OracleSharechainIdentity)
21+
{
22+
EXPECT_EQ(dgb::PoolConfig::IDENTIFIER_HEX, "4b62545b1a631afe");
23+
EXPECT_EQ(dgb::PoolConfig::DEFAULT_PREFIX_HEX, "1c0553f23ebfcffe");
24+
EXPECT_EQ(dgb::PoolConfig::TESTNET_IDENTIFIER_HEX, dgb::PoolConfig::IDENTIFIER_HEX);
25+
EXPECT_EQ(dgb::PoolConfig::TESTNET_PREFIX_HEX, dgb::PoolConfig::DEFAULT_PREFIX_HEX);
26+
}
27+
28+
// Consensus / protocol params conformed to the oracle (networks/digibyte.py).
29+
TEST(DGB_share_test, OracleConsensusParams)
30+
{
31+
EXPECT_EQ(dgb::PoolConfig::P2P_PORT, 5024u);
32+
EXPECT_EQ(dgb::PoolConfig::SEGWIT_ACTIVATION_VERSION, 35u);
33+
EXPECT_EQ(dgb::PoolConfig::MINIMUM_PROTOCOL_VERSION, 1700u);
34+
EXPECT_EQ(dgb::PoolConfig::ADVERTISED_PROTOCOL_VERSION, 3301u);
35+
EXPECT_EQ(dgb::PoolConfig::SHARE_PERIOD, 15u);
36+
EXPECT_EQ(dgb::PoolConfig::CHAIN_LENGTH, 2880u);
37+
}
38+
39+
// v35 donation = forrestv P2PK (4104ffd0…ac, 65-byte pubkey push + CHECKSIG).
40+
// v36 donation = combined P2SH (23-byte). get_donation_script() switches on
41+
// share_version at the SEGWIT/merged boundary.
42+
TEST(DGB_share_test, OracleDonationScript)
43+
{
44+
ASSERT_EQ(dgb::PoolConfig::DONATION_SCRIPT.size(), 67u);
45+
EXPECT_EQ(dgb::PoolConfig::DONATION_SCRIPT.front(), 0x41); // OP_PUSHBYTES_65
46+
EXPECT_EQ(dgb::PoolConfig::DONATION_SCRIPT[1], 0x04); // uncompressed pubkey tag
47+
EXPECT_EQ(dgb::PoolConfig::DONATION_SCRIPT[2], 0xff);
48+
EXPECT_EQ(dgb::PoolConfig::DONATION_SCRIPT[3], 0xd0);
49+
EXPECT_EQ(dgb::PoolConfig::DONATION_SCRIPT.back(), 0xac); // OP_CHECKSIG
50+
51+
EXPECT_EQ(dgb::PoolConfig::get_donation_script(35).size(), 67u); // v35 P2PK
52+
EXPECT_EQ(dgb::PoolConfig::get_donation_script(36).size(), 23u); // v36 combined P2SH
53+
}
54+
55+
// Address byte versions (D… P2PKH / S… P2SH) — DigiByte mainnet.
56+
TEST(DGB_share_test, AddressVersions)
57+
{
58+
EXPECT_EQ(dgb::CoinParams::ADDRESS_VERSION, 0x1e); // 30 — D prefix
59+
EXPECT_EQ(dgb::CoinParams::ADDRESS_P2SH_VERSION, 0x3f); // 63 — S prefix
60+
}
61+
62+
// Share-codec link smoke: dgb::load_share is the Scrypt-family wire entrypoint.
63+
// Referencing it forces the dgb OBJECT-lib share TU to link into this test exe,
64+
// build-verifying the pool/share stack (#132→#142) end-to-end.
65+
TEST(DGB_share_test, LoadShareSymbolLinks)
66+
{
67+
auto fn = static_cast<dgb::ShareType (*)(chain::RawShare&, NetService)>(&dgb::load_share);
68+
EXPECT_NE(fn, nullptr);
69+
}

0 commit comments

Comments
 (0)