diff --git a/auction/README.md b/auction/README.md index 7b8ffa0..4c3e129 100644 --- a/auction/README.md +++ b/auction/README.md @@ -29,7 +29,7 @@ The auction is conducted in a series of stages. ## Language Features and Concepts - `record` declarations -- `console.assert_eq` +- `assert_eq` - record ownership ## Running the Program diff --git a/auction/src/main.leo b/auction/src/main.leo index 28a8b4c..172633e 100644 --- a/auction/src/main.leo +++ b/auction/src/main.leo @@ -24,7 +24,7 @@ program auction.aleo { // The address of the auction runner is aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh. transition place_bid(bidder: address, amount: u64) -> Bid { // Ensure the caller is the auction bidder. - console.assert_eq(self.caller, bidder); + assert_eq(self.caller, bidder); // Return a new 'Bid' record for the auction bidder. return Bid { owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh, @@ -43,7 +43,7 @@ program auction.aleo { // In the event of a tie, the first bid is selected. transition resolve(first: Bid, second: Bid) -> Bid { // Ensure the caller is the auctioneer. - console.assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh); + assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh); // Resolve the winner of the auction. if (first.amount >= second.amount) { return first; @@ -58,7 +58,7 @@ program auction.aleo { // Assumes that the function is invoked only after all bids have been resolved. transition finish(bid: Bid) -> Bid { // Ensure the caller is the auctioneer. - console.assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh); + assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh); // Return 'is_winner' as 'true' in the winning 'Bid'. return Bid { owner: bid.bidder, diff --git a/basic_bank/README.md b/basic_bank/README.md index 941a30e..7bf99ac 100644 --- a/basic_bank/README.md +++ b/basic_bank/README.md @@ -26,7 +26,7 @@ Can you find any others? ## Language Features and Concepts - `record` declarations -- `console.assert_eq` +- `assert_eq` - core functions, e.g. `BHP256::hash` - record ownership - loops and bounded iteration diff --git a/basic_bank/src/main.leo b/basic_bank/src/main.leo index a458ebb..52281ad 100644 --- a/basic_bank/src/main.leo +++ b/basic_bank/src/main.leo @@ -20,7 +20,7 @@ program basic_bank.aleo { // Requires that the function caller is the bank. // The bank's address is aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a. transition issue(owner: address, amount: u64) -> Token { - console.assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a); + assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a); return Token { owner: owner, gates: 0u64, @@ -61,7 +61,7 @@ program basic_bank.aleo { // - `periods` : The number of periods to compound the interest over. // Requires that the function caller is the bank. transition withdraw(recipient: address, amount: u64, rate: u64, periods: u64) -> Token { - console.assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a); + assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a); let hash: field = BHP256::hash(recipient); let total: u64 = calculate_interest(amount, rate, periods); diff --git a/battleship/imports/board.leo b/battleship/imports/board.leo index efbd398..ee94c0a 100644 --- a/battleship/imports/board.leo +++ b/battleship/imports/board.leo @@ -45,7 +45,7 @@ program board.aleo { board: board_state, ) -> board_state { // Ensure this board hasn't been used to start a game before. - console.assert(!board.game_started); + assert(!board.game_started); return board_state { owner: board.owner, @@ -72,11 +72,11 @@ program board.aleo { let flip_bit: u64 = shoot - 1u64; // bitwise and operation let check_move: u64 = shoot & flip_bit; - console.assert_eq(check_move, 0u64); + assert_eq(check_move, 0u64); // Need to make sure shoot is a valid move given the played_tiles: no bits should overlap. let check_tiles: u64 = shoot & board.played_tiles; - console.assert_eq(check_tiles, 0u64); + assert_eq(check_tiles, 0u64); // Update played tiles. let played_tiles: u64 = board.played_tiles | shoot; diff --git a/battleship/imports/verify.leo b/battleship/imports/verify.leo index 84fd4dd..a484c6c 100644 --- a/battleship/imports/verify.leo +++ b/battleship/imports/verify.leo @@ -88,7 +88,7 @@ program verify.aleo { ) -> bool { // Check bitcount -- all other validations depend on the bitcount being correct. let num_bits: u64 = bitcount(ship); - console.assert_eq(num_bits, length); + assert_eq(num_bits, length); // Check horizontal bits of ship. let is_adjacent: bool = adjacency_check(ship, horizontal); // True if bits are adjacent horizontally. @@ -119,7 +119,7 @@ program verify.aleo { let ships: u64 = carrier | battleship | cruiser | destroyer; let num_bits: u64 = bitcount(ships); - console.assert_eq(num_bits, 14u64); // Given 4 individually-valid ships, a valid combination should yield exactly 14 flipped bits. + assert_eq(num_bits, 14u64); // Given 4 individually-valid ships, a valid combination should yield exactly 14 flipped bits. return ships; } diff --git a/battleship/src/main.leo b/battleship/src/main.leo index 94f427d..5b7401e 100644 --- a/battleship/src/main.leo +++ b/battleship/src/main.leo @@ -20,16 +20,16 @@ program battleship.aleo { ) -> board.leo/board_state.record { // Verify that each individual ship placement bitstring is valid. let valid_carrier: bool = verify.leo/validate_ship(carrier, 5u64, 31u64, 4311810305u64); - console.assert(valid_carrier); + assert(valid_carrier); let valid_battleship: bool = verify.leo/validate_ship(battleship, 4u64, 15u64, 16843009u64); - console.assert(valid_battleship); + assert(valid_battleship); let valid_cruiser: bool = verify.leo/validate_ship(cruiser, 3u64, 7u64, 65793u64); - console.assert(valid_cruiser); + assert(valid_cruiser); let valid_destroyer: bool = verify.leo/validate_ship(destroyer, 2u64, 3u64, 257u64); - console.assert(valid_destroyer); + assert(valid_destroyer); // Create the board with all the ship placements combined. let board: u64 = verify.leo/create_board(carrier, battleship, cruiser, destroyer); @@ -62,8 +62,8 @@ program battleship.aleo { move_start: move.leo/move.record, ) -> (board.leo/board_state.record, move.leo/move.record) { // Validate that the move players and board players match each other. - console.assert_eq(board.player_1, move_start.player_2); - console.assert_eq(board.player_2, move_start.player_1); + assert_eq(board.player_1, move_start.player_2); + assert_eq(board.player_2, move_start.player_1); let state: board_state = board.leo/start_board(board); let dummy: move = move.leo/start_game(board.player_2); @@ -83,11 +83,11 @@ program battleship.aleo { ) -> (board.leo/board_state.record, move.leo/move.record) { // Verify the board has been started. This prevents players from starting a game and then creating // a brand new board to play with. - console.assert(board.game_started); + assert(board.game_started); // Validate that the move players and board players match each other. - console.assert_eq(board.player_1, move_incoming.player_2); - console.assert_eq(board.player_2, move_incoming.player_1); + assert_eq(board.player_1, move_incoming.player_2); + assert_eq(board.player_2, move_incoming.player_1); // Play coordinate on own board. Will fail if not a valid move. let hit_or_miss: board_state = board.leo/update_played_tiles(board, shoot); diff --git a/tictactoe/src/main.leo b/tictactoe/src/main.leo index a2c44d4..70c7da7 100644 --- a/tictactoe/src/main.leo +++ b/tictactoe/src/main.leo @@ -57,9 +57,9 @@ program tictactoe.aleo { // If an entry is already occupied, the move is invalid and the board is returned unchanged. transition make_move(player: u8, row: u8, col: u8, board: Board) -> (Board, u8) { // Check that inputs are valid. - console.assert(player == 1u8 || player == 2u8); - console.assert(1u8 <= row && row <= 3u8); - console.assert(1u8 <= col && col <= 3u8); + assert(player == 1u8 || player == 2u8); + assert(1u8 <= row && row <= 3u8); + assert(1u8 <= col && col <= 3u8); // Unpack the entries in the board into variables. let r1c1: u8 = board.r1.c1; diff --git a/vote/src/main.leo b/vote/src/main.leo index 6e9032a..126b923 100644 --- a/vote/src/main.leo +++ b/vote/src/main.leo @@ -35,7 +35,7 @@ program vote.aleo { // Propose a new proposal to vote on. transition propose(public info: ProposalInfo) -> Proposal { // Authenticate proposer. - console.assert_eq(self.caller, info.proposer); + assert_eq(self.caller, info.proposer); // Generate a new proposal id. let id: field = BHP256::hash(info.title);