From 2e96c62e966db145b55acf3756d41b7cbf8eace1 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 02:33:14 +0000 Subject: [PATCH] store: test the records relay's name checks --- tests/Bots/StoreService/NamesRecordsTests.hs | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/Bots/StoreService/NamesRecordsTests.hs b/tests/Bots/StoreService/NamesRecordsTests.hs index 77fd9454c6..2e790bf761 100644 --- a/tests/Bots/StoreService/NamesRecordsTests.hs +++ b/tests/Bots/StoreService/NamesRecordsTests.hs @@ -68,6 +68,7 @@ namesRecordsTests = describe "StoreService names: records" $ do describe "relay" $ do it "relays an edit with viem's calldata and answers its hash once mined" $ testRelayMined g it "refuses a wrong signer or a passed deadline before any row or gas" $ testRefusedBeforeRow g + it "refuses an edit of a name on another resolver, or past its expiry and grace, before any row or gas" $ testRefusedNameState g it "leaves the owner's cap untouched by ten edits a non-owner signs" $ testNonOwnerCap g it "checks a refused edit's repeat anew" $ testRefusedRepeat g it "refuses the eleventh relayed edit of a name within an hour, with the real wait" $ testCap g @@ -280,6 +281,19 @@ testRefusedBeforeRow g = withSetup g $ \s@Setup {node, records} -> do editRows s `shouldReturn` 0 sentTransactions node `shouldReturn` [] +testRefusedNameState :: TVar ChaChaDRG -> IO () +testRefusedNameState g = withSetup g $ \s@Setup {node, records} -> do + req <- ownerEdit s viemChannelLink + answerCall node registry (selector "resolver(bytes32)" <> nodeBytes aliceNode) $ Returns $ addressWord otherResolver + relayEdit records req `shouldReturn` EARefused + answerCall node registry (selector "resolver(bytes32)" <> nodeBytes aliceNode) $ Returns $ addressWord fakeResolver + -- the registry still names the owner, but the name lapsed: expiry and grace are before the latest block + answerCall node fakeBaseRegistrar (selector "nameExpires(uint256)" <> unLabel alice) $ Returns $ uint256 (genesis - gracePeriod - 1) + answerCall node fakeController (selector "reservedNames(bytes32)" <> unLabel alice) $ Returns $ uint256 (0 :: Int) + relayEdit records req `shouldReturn` EARefused + editRows s `shouldReturn` 0 + sentTransactions node `shouldReturn` [] + testNonOwnerCap :: TVar ChaChaDRG -> IO () testNonOwnerCap g = withSetup g $ \s@Setup {node, records} -> do other <- newEphemeralWallet g @@ -637,8 +651,13 @@ nameExpiry, gracePeriod :: Word64 nameExpiry = 1861833600 gracePeriod = 7776000 -registry :: Address +registry, otherResolver :: Address registry = address "0x5fbdb2315678afecb367f032d93f642f64180aa3" +otherResolver = address "0x4826533b4897376654bb4d4ad88b7fafd0c98528" + +-- | The fake node's first block time. +genesis :: Word64 +genesis = deadline - 3600 -- | The name code of BIP-39 entropy zero, the wallet of "abandon ... about". viemCode :: Text