コード例 #1
0
        private async Task DeployContractsAsync()
        {
            var category = KernelConstants.CodeCoverageRunnerCategory;
            var code     = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Configuration")).Value;

            ConfigurationContractAddress = await DeploySystemSmartContract(category, code,
                                                                           ConfigurationSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            ConfigurationStub =
                GetTester <ConfigurationContainer.ConfigurationStub>(ConfigurationContractAddress,
                                                                     DefaultSenderKeyPair);
        }
コード例 #2
0
        private async Task DeployContractsAsync()
        {
            var category = KernelConstants.CodeCoverageRunnerCategory;
            var code     = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Configuration")).Value;

            OptionalLogEventListeningService <IBlockAcceptedLogEventHandler> .Enabled = true;
            ConfigurationContractAddress = await DeploySystemSmartContract(category, code,
                                                                           ConfigurationSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            _configurationStub =
                GetTester <ConfigurationContainer.ConfigurationStub>(ConfigurationContractAddress,
                                                                     DefaultSenderKeyPair);

            var consensusContractCode    = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Consensus.AEDPoS")).Value;
            var consensusContractAddress = await DeploySystemSmartContract(category, consensusContractCode,
                                                                           ConsensusSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            var consensusStub = GetTester <AEDPoSContractImplContainer.AEDPoSContractImplStub>(consensusContractAddress,
                                                                                               DefaultSenderKeyPair);

            await consensusStub.FirstRound.SendAsync(
                new MinerList
            {
                Pubkeys = { ByteString.CopyFrom(DefaultSenderKeyPair.PublicKey) }
            }.GenerateFirstRoundOfNewTerm(4000, TimestampHelper.GetUtcNow())
                );

            var parliamentAuthContractCode    = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("ParliamentAuth")).Value;
            var parliamentAuthContractAddress = await DeploySystemSmartContract(category, parliamentAuthContractCode,
                                                                                ParliamentAuthSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            _parliamentAuthStub = GetTester <ParliamentAuthContractContainer.ParliamentAuthContractStub>(parliamentAuthContractAddress,
                                                                                                         DefaultSenderKeyPair);

            await _parliamentAuthStub.Initialize.SendAsync(new InitializeInput
            {
                GenesisOwnerReleaseThreshold = 1,
                ProposerAuthorityRequired    = true,
                PrivilegedProposer           = Address.FromPublicKey(DefaultSenderKeyPair.PublicKey)
            });

            var chain = await _blockchainService.GetChainAsync();

            await _blockchainService.SetIrreversibleBlockAsync(chain, chain.BestChainHeight, chain.BestChainHash);
        }
コード例 #3
0
        protected async Task DeployContractsAsync()
        {
            var category = KernelConstants.CodeCoverageRunnerCategory;
            var code     = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Configuration")).Value;

            OptionalLogEventProcessingService <IBlockAcceptedLogEventProcessor> .Enabled = true;
            ConfigurationContractAddress = await DeploySystemSmartContract(category, code,
                                                                           ConfigurationSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            ConfigurationStub =
                GetTester <ConfigurationContainer.ConfigurationStub>(ConfigurationContractAddress,
                                                                     DefaultSenderKeyPair);

            var consensusContractCode    = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Consensus.AEDPoS")).Value;
            var consensusContractAddress = await DeploySystemSmartContract(category, consensusContractCode,
                                                                           ConsensusSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            var consensusStub = GetTester <AEDPoSContractImplContainer.AEDPoSContractImplStub>(consensusContractAddress,
                                                                                               DefaultSenderKeyPair);

            await consensusStub.FirstRound.SendAsync(
                new MinerList
            {
                Pubkeys = { ByteString.CopyFrom(DefaultSenderKeyPair.PublicKey) }
            }.GenerateFirstRoundOfNewTerm(4000, TimestampHelper.GetUtcNow())
                );

            var parliamentContractCode    = Codes.Single(kv => kv.Key.Split(",").First().EndsWith("Parliament")).Value;
            var parliamentContractAddress = await DeploySystemSmartContract(category, parliamentContractCode,
                                                                            ParliamentSmartContractAddressNameProvider.Name, DefaultSenderKeyPair);

            ParliamentContractStub = GetTester <ParliamentContractImplContainer.ParliamentContractImplStub>(parliamentContractAddress,
                                                                                                            DefaultSenderKeyPair);

            await ParliamentContractStub.Initialize.SendAsync(new InitializeInput
            {
                ProposerAuthorityRequired = true,
                PrivilegedProposer        = Address.FromPublicKey(DefaultSenderKeyPair.PublicKey)
            });
        }