Truffle
我應該關心這些基準值嗎?
假設我有一個契約,為了這篇文章,它繼承了 OpenZeppelin 的
Ownable
. 我做了一個小的更新(就程式碼/複雜性而言:覆蓋和恢復以禁用方法)。然後我添加了測試,結果是這樣的:Contract: SampleMetaverse ✓ does not allow renouncing the ownership (using: account 0) ✓ does not allow transferring ownership to others than the owner (using: account 1) ✓ allows transferring ownership to self (using: account 0) (407ms) ✓ allows transferring ownership to others (using: account 0) (89ms) ✓ does not allow renouncing the ownership (using: account 1) ✓ allows transferring ownership to self (using: account 1) (115ms) ✓ allows transferring ownership to others (using: account 1) (92ms)
我看到以毫秒為單位的數字是紅色的(這是一個松露測試)。我應該在多大程度上關心這個?
契約(我正在測試的部分)實際上是這樣的:
abstract contract SafeOwnable is Ownable { constructor() Ownable() {} /** * @dev Trying to renounce the ownership is forbidden in these contracts. */ function renounceOwnership() public override onlyOwner { revert("SafeOwnable: ownership cannot be renounced"); } }
不用擔心。
發紅是測試框架的產物,碰巧認為時間有點偏高。這是無關緊要的。
以塊形式到達的交易可以被認為是過去執行的。因此,所有節點都處於追趕模式。任何速度相當快的電腦都可以在下一個塊到達之前處理塊中的所有內容。區塊的最大復雜度受區塊氣體限制的限制。
您應該關注交易的最大氣體消耗量和時間複雜度(目標為O(1)),但時間時間完全無關緊要。
希望能幫助到你。