示例#1
0
        public void ContractAuditor_AcsRequired_Test()
        {
            var whiteList = new List <string>
            {
                "System.Collection",
                "System.Linq"
            };
            var blackList = new List <string>
            {
                "System.Random",
                "System.DateTime"
            };

            _auditor = new CSharpContractAuditor(whiteList, blackList);

            var requireAcs = new RequiredAcs();

            requireAcs.AcsList = new List <string> {
                "acs1"
            };
            Should.Throw <CSharpInvalidCodeException>(() => _auditor.Audit(_badContractCode, requireAcs));

            Should.NotThrow(() => _auditor.Audit(_systemContractCode, requireAcs));

            requireAcs.AcsList.Add("acs8");
            Should.NotThrow(() => _auditor.Audit(_systemContractCode, requireAcs));

            requireAcs.RequireAll = true;
            Should.Throw <CSharpInvalidCodeException>(() => _auditor.Audit(_systemContractCode, requireAcs));
        }
示例#2
0
        public void ContractAuditor_Basic_Test()
        {
            var whiteList = new List <string>
            {
                "System.Collection",
                "System.Linq"
            };
            var blackList = new List <string>
            {
                "System.Random",
                "System.DateTime"
            };

            _auditor = new CSharpContractAuditor(blackList, whiteList);

            Should.Throw <InvalidCodeException>(() => _auditor.Audit(_badContractCode, _requiredAcs));
        }
示例#3
0
 public void Audit(byte[] code)
 {
     _auditor.Audit(code, _requiredAcs);
 }
 public void Audit(byte[] code, bool isSystemContract)
 {
     _auditor.Audit(code, _requiredAcs, isSystemContract);
 }