public WorkEventLogTest()
        {
            this.address           = this.addressFactory.Create();
            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.contractRegistry  = new ContractRegistry();
            this.workTracker       = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                                 this.permissionManager.Address);
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.workTracker);

            this.permissionManager.ExecuteAction(addPerm);

            var eventSet = new HashSet <WorkEventArgs>()
            {
                new WorkEventArgs(5, new DateTime(2019, 5, 13), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 14), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 15), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 16), this.address),
            };

            this.eventLog = new WorkEventLog(30, eventSet, this.workTracker);
        }
        public void InitializeMember_BurnTokensOnMint_AssertEqual()
        {
            this.member = new Member(this.addressFactory.Create(), this.contractRegistry, this.permissionManager.Address);
            this.contractRegistry.RegisterContract(this.member);
            var mintedStrategy = new AddTokensMintedStrategyAction(
                string.Empty, this.member.Address, this.tokenManager.Address, new BurnTokensReceivedStrategy());

            this.permissionManager.ExecuteAction(mintedStrategy);

            var addTokenMintPermission = new AddPermissionAction(
                string.Empty,
                this.member.Address,
                new Permission(typeof(TokensMintedAction)),
                this.tokenManager.Address);

            this.permissionManager.ExecuteAction(addTokenMintPermission);

            var addTokenBurnPermission = new AddPermissionAction(
                string.Empty,
                this.tokenManager.Address,
                new Permission(typeof(BurnAction)),
                this.member.Address);

            this.permissionManager.ExecuteAction(addTokenBurnPermission);

            var mintAction = new MintAction(
                string.Empty,
                this.tokenManager.Address,
                400,
                this.member.Address);

            this.permissionManager.ExecuteAction(mintAction);

            Assert.Equal(0, this.tokenManager.TaggedBalanceOf(this.member.Address).TotalBalance);
        }
Exemple #3
0
        private void InitializePermissions()
        {
            var addPermAction = new AddPermissionAction(
                string.Empty,
                this.taskRegistry.Address,
                new Permission(typeof(AddTaskAction)),
                this.permissionManager.Address);

            this.permissionManager.ExecuteAction(addPermAction);
            addPermAction = new AddPermissionAction(
                string.Empty,
                this.taskRegistry.Address,
                new Permission(typeof(RemoveTaskAction)),
                this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPermAction);
            addPermAction = new AddPermissionAction(
                string.Empty,
                this.taskRegistry.Address,
                new Permission(typeof(ChangeDefaultSplitterAction)),
                this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPermAction);

            // work traker
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.permissionManager.ExecuteAction(addPerm);
        }
Exemple #4
0
        protected override void HandleMessage(Message message)
        {
            switch (message.Type)
            {
            case AddPermissionAction.Type:
                this.Acl.AddPermission(AddPermissionAction.GetPermission(message.Payload));
                break;

            case RemovePermissionAction.Type:
                this.Acl.RemovePermission(RemovePermissionAction.GetPermission(message.Payload));
                break;
            }
        }
        private void ConfigurePermissions()
        {
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.permissionManager.ExecuteAction(addPerm);

            perm    = new Permission(typeof(AddTrackerGuardAction));
            addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                              this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPerm);

            perm    = new Permission(typeof(RemoveTrackerGuardAction));
            addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                              this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPerm);
        }
Exemple #6
0
        private void InitializePermissions()
        {
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.permissionManager.ExecuteAction(addPerm);

            perm    = new Permission(typeof(MintAction));
            addPerm = new AddPermissionAction(string.Empty, this.tokenManager.Address, perm,
                                              this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPerm);

            perm    = new Permission(typeof(TransferAction));
            addPerm = new AddPermissionAction(string.Empty, this.tokenManager.Address, perm,
                                              this.permissionManager.Address);
            this.permissionManager.ExecuteAction(addPerm);
        }
Exemple #7
0
        private void CreateTokenInteractionPermissions(Address address)
        {
            var transferPermission = new AddPermissionAction(
                string.Empty,
                this.tokenManager.Address,
                new Permission(typeof(TransferAction)),
                address);

            this.permissionManager.ExecuteAction(transferPermission);

            transferPermission = new AddPermissionAction(
                string.Empty,
                this.tokenManager.Address,
                new Permission(typeof(TransferAction)),
                this.splitterPerHours.Address);
            this.permissionManager.ExecuteAction(transferPermission);

            var receiveTokens = new AddPermissionAction(
                string.Empty,
                address,
                new Permission(typeof(TokensReceivedAction)),
                this.tokenManager.Address);

            this.permissionManager.ExecuteAction(receiveTokens);

            var receiveMintedTokens = new AddPermissionAction(
                string.Empty,
                address,
                new Permission(typeof(TokensMintedAction)),
                this.tokenManager.Address);

            this.permissionManager.ExecuteAction(receiveMintedTokens);

            receiveTokens = new AddPermissionAction(
                string.Empty,
                this.splitterPerHours.Address,
                new Permission(typeof(TokensReceivedAction)),
                this.tokenManager.Address);
            this.permissionManager.ExecuteAction(receiveTokens);
        }
        public MembersTest()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.tokenManager      = new TokenManager(
                this.addressFactory.Create(),
                this.permissionManager.Address,
                this.contractRegistry,
                tokenTagger,
                tokenPicker);
            var addMintPermission = new AddPermissionAction(
                string.Empty,
                this.tokenManager.Address,
                new Permission(typeof(MintAction)),
                this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.tokenManager);
            this.permissionManager.ExecuteAction(addMintPermission);
        }