मुख्य सामग्री पर जाएं
कुछ प्रकार के tests के लिए time के माध्यम से skip करना उपयोगी है। यह dashboard से Configure next block के साथ, या RPC पर Virtual Environments पर उपलब्ध 2 Admin RPC methods के साथ संभव है: evm_increaseTime और evm_setNextBlockTimestamp।

सही समय प्राप्त करना

एक transaction या eth_call के execution के दौरान एक contract के अंदर block.timestamp को access किया जाता है, तो value इस पर निर्भर करेगी कि target block (latest या pending) block है या नहीं:
  • pending block के लिए: block.timestamp == time.now() + adjustment_offset। यह time-adjustment methods द्वारा adjusted current time को दर्शाता है।
  • latest block के लिए: block.timestamp == latest_block.timestamp। यह सबसे हाल ही में mined block का timestamp है।
adjustment_offset time-adjustment methods से आता है:
  1. evm_setNextBlockTimestamp: अगले block के लिए timestamp पर time को skip करता है: adjustment_offset = timestamp - time.now()।
  2. evm_increaseTime: time को एक relative amount से आगे बढ़ाता है। adjustment_offset += increase_value

उदाहरण

एक offset से time बढ़ाएं

showLineNumbers

pending block के लिए timestamp सेट करें

showLineNumbers

Dashboard से अगला block configure करें

Virtual Environment header में, Mine के बगल वाला menu खोलें और Configure next block चुनें।
Configure next block dialog जिसमें 1 पर सेट Add blocks field, Time configuration के विकल्प Increase time और Set UNIX timestamp, 10 seconds का value, Mainnet block 25265709 को 25265710 में बदलते हुए दिखाने वाली preview table, और Fetch latest, Mine with next transaction, तथा Mine now buttons हैं

Mine के बगल वाले menu से खोला गया Configure next block dialog।