2017-03-14 10 views
12

समस्या तब उत्पन्न नहीं होती है जब मैं यह जांचना चाहता हूं कि कोई स्ट्रिंग मान सही है या नहीं। संख्याओं को सही ढंग से जोर दिया जाता है और जब वे संकलित करने की कोशिश कर रहे होते हैं तो एक त्रुटि संदेश नहीं लौटाते हैं।सदस्य बराबर प्रकार (लाइब्रेरी आर्टर्ट)

Error: Member "equal" is not available in type(library Assert) outside of storage. 
     Assert.equal(token.symbol(), "$", "The symbol of the token should be $"); 
     ^----------^ 
Compiliation failed. See above. 

Token.sol

pragma solidity ^0.4.8; 

contract Token { 
    /* The amount of tokens a person will get for 1 ETH */ 
    uint256 public exchangeRate; 

    /* The name of the token */ 
    string public name; 

    /* The address which controls the token */ 
    address public owner; 

    /* The symbol of the token */ 
    string public symbol; 

    /* The balances of all registered addresses */ 
    mapping (address => uint256) balances; 

    /* Token constructor */ 
    function Token(uint256 _exchangeRate, string _name, string _symbol) { 
     exchangeRate = _exchangeRate; 
     name = _name; 
     owner = msg.sender; 
     symbol = _symbol; 
    } 

    function getBalance(address account) returns (uint256 balance) { 
     return balances[account]; 
    } 
} 

TestToken.sol

pragma solidity ^0.4.8; 

// Framework libraries 
import "truffle/Assert.sol"; 
import "truffle/DeployedAddresses.sol"; 

// Custom libraries and contracts 
import "../contracts/Token.sol"; 

contract TestToken { 
    function testExchangeRate() { 
     Token token = new Token(500, "Dollar", "$"); 

     uint256 expected = 500; 

     Assert.equal(token.exchangeRate(), expected, "The exchange rate should be 500 tokens for 1 ETH"); 
    } 

    function testSymbol() { 
     Token token = new Token(500, "Dollar", "$"); 

     Assert.equal(token.symbol(), "$", "The symbol of the token should be $"); 
    } 
} 

क्यों करता है: हालांकि, जब मैं एक स्ट्रिंग का दावा करने की कोशिश है, यह निम्न त्रुटि संदेश देता है ऐसा होता है और आप इसे कैसे हल करते हैं?

+0

शायद यह मदद कर सकता है? http://ethereum.stackexchange.com/q/1701 – default

+2

इस विषय के बारे में कोई खबर? –

उत्तर

-3

string से दूसरे को बदलने का प्रयास करें, bytes32 कहें। यह काम करता हैं।

सभी बेहतरीन।

1

अब तक सॉलिडेंस अनुबंधों के बीच रिटर्निंग स्ट्रिंग का समर्थन नहीं करता है। क्योंकि कॉल के समय स्ट्रिंग की लंबाई ज्ञात नहीं है। इसलिए वे केवल बाइट्स 32 जैसे निश्चित आकार के आर्यों का समर्थन करते हैं।

आपके स्ट्रिंग के विभिन्न हिस्सों को स्टोर करने के लिए आपके पास एकाधिक बाइट्स 32 हो सकते हैं।

संबंधित मुद्दे