diff --git a/.env b/.env index b42b0ff..c1eaff7 100644 --- a/.env +++ b/.env @@ -3,3 +3,4 @@ FIRST_CHAIN_MAINTAINER=YOUR_NAME CONTRACTS_LIMIT=2 SIGNATURES_LIMIT=5 REDIS_URL=redis://redis:6379 +ENV_MACHINE=docker diff --git a/app/controllers/api/v1/block_confirmations_controller.rb b/app/controllers/api/v1/block_confirmations_controller.rb index 224226c..c89b333 100644 --- a/app/controllers/api/v1/block_confirmations_controller.rb +++ b/app/controllers/api/v1/block_confirmations_controller.rb @@ -11,15 +11,15 @@ def confirm_block assign_contract end - def transactions_to_mine - return unauthorized_response unless find_user_by_header - ticket = Ticket.find_by(user_id: @user.id) - return ticket_not_found_response unless ticket.present? - transactions_ids = ticket.transaction_id_list - transactions = Transaction.where(id: transactions_ids) - transactions_json = transactions.to_json - render json: transactions_json, status: :ok - end + # def transactions_to_mine + # return unauthorized_response unless find_user_by_header + # ticket = Ticket.find_by(user_id: @user.id) + # return ticket_not_found_response unless ticket.present? + # transactions_ids = ticket.transaction_id_list + # transactions = Transaction.where(id: transactions_ids) + # transactions_json = transactions.to_json + # render json: transactions_json, status: :ok + # end def info_to_mine return unauthorized_response unless find_user_by_header @@ -31,11 +31,11 @@ def info_to_mine private def find_user_by_header - return unless request.headers["X-Api-Key"].present? - api_key = request.headers["X-Api-Key"] + return unless request.headers["X-API-KEY"].present? + api_key = request.headers["X-API-KEY"] @user = User.find_by(api_key: api_key) return unless @user.present? - @user.api_secret == request.headers["X-Api-Secret"] + @user.api_secret == request.headers["X-API-SECRET"] end def unauthorized_response diff --git a/app/controllers/contracts_controller.rb b/app/controllers/contracts_controller.rb index 4e6221c..da9e243 100644 --- a/app/controllers/contracts_controller.rb +++ b/app/controllers/contracts_controller.rb @@ -17,9 +17,4 @@ def show def set_contract @contract = Contract.find(params[:id]) end - - # Only allow a list of trusted parameters through. - def contract_params - params.require(:contract).permit(:first_sig, :second_sig, :third_sig, :fourth_sig, :status, :transaction_id) - end end diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index f7595de..30695e0 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -13,61 +13,9 @@ def index def show end - # GET /pools/new - def new - @pool = Pool.new - end - - # GET /pools/1/edit - def edit - end - - # POST /pools or /pools.json - def create - @pool = Pool.new(pool_params) - - respond_to do |format| - if @pool.save - format.html { redirect_to pool_url(@pool), notice: "Pool was successfully created." } - format.json { render :show, status: :created, location: @pool } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @pool.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /pools/1 or /pools/1.json - def update - respond_to do |format| - if @pool.update(pool_params) - format.html { redirect_to pool_url(@pool), notice: "Pool was successfully updated." } - format.json { render :show, status: :ok, location: @pool } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @pool.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /pools/1 or /pools/1.json - def destroy - @pool.destroy - - respond_to do |format| - format.html { redirect_to pools_url, notice: "Pool was successfully destroyed." } - format.json { head :no_content } - end - end - private # Use callbacks to share common setup or constraints between actions. def set_pool @pool = Pool.find(params[:id]) end - - # Only allow a list of trusted parameters through. - def pool_params - params.require(:pool).permit(:block_id, :users_count, :signatures_count, :amount, :stage) - end end diff --git a/app/controllers/signatures_controller.rb b/app/controllers/signatures_controller.rb index 7c18c9d..32f4d18 100644 --- a/app/controllers/signatures_controller.rb +++ b/app/controllers/signatures_controller.rb @@ -17,9 +17,4 @@ def show def set_signature @signature = Signature.find(params[:id]) end - - # Only allow a list of trusted parameters through. - def signature_params - params.require(:signature).permit(:signature, :time_ref, :contract_id, :common_word, :symbol_sequence, :number_sequence, :verify_sig, :block_hash, :signature_hash) - end end diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index bcb3080..b88dff0 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -18,10 +18,6 @@ def new @ticket = Ticket.new end - # GET /tickets/1/edit - def edit - end - # POST /tickets or /tickets.json def create return no_transactions_response if block_transactions.empty? @@ -29,29 +25,6 @@ def create redirect_to tickets_path, notice: "Processing ticket, please wait, wait a minute and refresh the page" end - # PATCH/PUT /tickets/1 or /tickets/1.json - def update - respond_to do |format| - if @ticket.update(ticket_params) - format.html { redirect_to ticket_url(@ticket), notice: "Ticket was successfully updated." } - format.json { render :show, status: :ok, location: @ticket } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @ticket.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /tickets/1 or /tickets/1.json - def destroy - @ticket.destroy - - respond_to do |format| - format.html { redirect_to tickets_url, notice: "Ticket was successfully destroyed." } - format.json { head :no_content } - end - end - private def create_ticket CreateTicketWorker.perform_async(current_user.id, current_pool.id, time_ref) diff --git a/app/views/transactions/_transaction.html.slim b/app/views/transactions/_transaction.html.slim index ed7b57d..5b9c3f6 100644 --- a/app/views/transactions/_transaction.html.slim +++ b/app/views/transactions/_transaction.html.slim @@ -3,9 +3,8 @@ div id="#{dom_id transaction}" strong Sended by: =< transaction.sender p - strong Receiver By: + strong Receiver By: =< transaction.receiver - / only show the information below if the Show page is being rendered - if action_name == "show" p strong Amount: diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index c012d03..5cc4058 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -5,7 +5,7 @@ <%= render "users/shared/error_messages", resource: resource %>
<%= f.label :username, class: "text-white" %>
- (10 characters minimum) + (10 characters minimum)
<%= f.text_field :username, autofocus: true, autocomplete: "username",class: "px-4 py-2 rounded text-black border-2 border-purple-300 focus_border-purple-900" %>
diff --git a/config/routes/api.rb b/config/routes/api.rb index a11a8b5..d701a1b 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -3,7 +3,7 @@ namespace :api do namespace :v1 do post "confirm_block", to: "block_confirmations#confirm_block" - get "tr_to_mine", to: "block_confirmations#transactions_to_mine" + # get "tr_to_mine", to: "block_confirmations#transactions_to_mine" get "info_to_mine", to: "block_confirmations#info_to_mine" end end diff --git a/coverage/.last_run.json b/coverage/.last_run.json index 8b6d1e7..d07b8d2 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,5 +1,5 @@ { "result": { - "line": 70.1 + "line": 80.9 } } diff --git a/coverage/.resultset.json b/coverage/.resultset.json index 51fa512..747e8d6 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -1,7 +1,7 @@ { "RSpec": { "coverage": { - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/user.rb": { + "/myapp/app/models/user.rb": { "lines": [ null, null, @@ -23,33 +23,33 @@ null, 1, 1, - 0, + 71, null, null, 1, - 0, - 0, - 0, + 71, + 71, + 71, null, - 0, + 71, null, - 0, + 71, null, - 0, + 71, null, - 0, - 0, - 0, + 71, + 71, + 71, null, null, 1, - 0, - 0, + 71, + 71, null, null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/application_record.rb": { + "/myapp/app/models/application_record.rb": { "lines": [ null, null, @@ -58,7 +58,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/application_helper.rb": { + "/myapp/app/helpers/application_helper.rb": { "lines": [ null, null, @@ -66,7 +66,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/blocks_helper.rb": { + "/myapp/app/helpers/blocks_helper.rb": { "lines": [ null, null, @@ -74,7 +74,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/chains_helper.rb": { + "/myapp/app/helpers/chains_helper.rb": { "lines": [ null, null, @@ -82,7 +82,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/contracts_helper.rb": { + "/myapp/app/helpers/contracts_helper.rb": { "lines": [ null, null, @@ -90,7 +90,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/pools_helper.rb": { + "/myapp/app/helpers/pools_helper.rb": { "lines": [ null, null, @@ -98,7 +98,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/signatures_helper.rb": { + "/myapp/app/helpers/signatures_helper.rb": { "lines": [ null, null, @@ -106,7 +106,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/tickets_helper.rb": { + "/myapp/app/helpers/tickets_helper.rb": { "lines": [ null, null, @@ -114,7 +114,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/transactions_helper.rb": { + "/myapp/app/helpers/transactions_helper.rb": { "lines": [ null, null, @@ -122,7 +122,7 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/helpers/wallets_helper.rb": { + "/myapp/app/helpers/wallets_helper.rb": { "lines": [ null, null, @@ -130,579 +130,263 @@ null ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/lib/osbc/osbc.rb": { + "/myapp/app/controllers/application_controller.rb": { "lines": [ null, null, + null, + 1, + 1, 1, 1, 1, null, null, 1, - null - ] - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/lib/outerspace/blockchain.rb": { - "lines": [ + 1, + null, + null, + 1, + 0, + 0, + 0, + 0, null, null, 1, null, + null, 1, + null, 1, 1, + 35, null, null, - null - ] - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/lib/outerspace/blockchain/version.rb": { - "lines": [ + 1, + 36, null, null, 1, + 105, + null, + null, 1, + 35, + null, + null, 1, + 35, null, - null - ] - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/api/v1/block_confirmations_controller.rb": { - "lines": [ null, + 1, + 35, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 35, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 35, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 35, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, + 1, + 35, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + 1, + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/application_controller.rb": { + "/myapp/app/controllers/transactions_controller.rb": { "lines": [ null, null, + 1, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0, null, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, + 1, null, null, - 0, null, - 0, - 0, - 0, - 0, + 1, + 2, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, + 1, + 1, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null, + null, + 1, + 2, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/blocks_controller.rb": { + "/myapp/app/controllers/users/confirmations_controller.rb": { "lines": [ null, null, - 0, - 0, + 1, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, - 0, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/chains_controller.rb": { - "lines": [ null, null, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, null, - 0, null, - 0, - 0, - 0, - null, - null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/contracts_controller.rb": { + "/myapp/app/controllers/users/omniauth_callbacks_controller.rb": { "lines": [ null, null, - 0, - 0, - null, - null, - 0, - 0, - 0, - null, - null, - 0, - 0, + 1, null, - 0, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/pools_controller.rb": { - "lines": [ null, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, null, - 0, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/signatures_controller.rb": { + "/myapp/app/controllers/users/passwords_controller.rb": { "lines": [ null, null, - 0, - 0, - null, + 1, null, - 0, - 0, - 0, null, null, - 0, - 0, null, - 0, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/tickets_controller.rb": { - "lines": [ null, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, null, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/transactions_controller.rb": { + "/myapp/app/controllers/users/registrations_controller.rb": { "lines": [ null, null, - 0, - 0, - 0, + 1, + 1, null, null, - 0, - 0, - 0, null, null, - 0, - 0, null, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/confirmations_controller.rb": { - "lines": [ null, null, - 0, null, null, null, @@ -722,30 +406,34 @@ null, null, null, + 1, null, + 1, + 1, null, null, null, null, null, null, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/omniauth_callbacks_controller.rb": { - "lines": [ null, null, - 0, + 1, + 1, + null, null, null, null, null, null, + null + ] + }, + "/myapp/app/controllers/users/sessions_controller.rb": { + "lines": [ null, null, + 1, null, null, null, @@ -765,20 +453,18 @@ null, null, null, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/passwords_controller.rb": { - "lines": [ null, null, - 0, null, null, + null + ] + }, + "/myapp/app/controllers/users/unlocks_controller.rb": { + "lines": [ null, null, + 1, null, null, null, @@ -805,116 +491,285 @@ null, null, null, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/registrations_controller.rb": { + "/myapp/app/controllers/wallets_controller.rb": { "lines": [ null, null, - 0, - 0, + 1, + 1, + 1, null, + 1, + 2, null, null, + 1, null, null, + 1, + 1, + 1, null, + null + ] + }, + "/myapp/app/mailers/application_mailer.rb": { + "lines": [ null, null, - 0, - 0, - 0, + 1, + 1, + 1, + null + ] + }, + "/myapp/app/models/acceptable_number_sequence.rb": { + "lines": [ + null, + null, + 1, + null + ] + }, + "/myapp/app/models/acceptable_symbol_sequence.rb": { + "lines": [ null, null, + 1, + null + ] + }, + "/myapp/app/models/acceptable_word.rb": { + "lines": [ null, null, + 1, + null + ] + }, + "/myapp/app/models/block.rb": { + "lines": [ null, null, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, null, + 1, + 1, + 68, null, + null + ] + }, + "/myapp/app/models/chain.rb": { + "lines": [ null, null, + 1, + 1, + 1, + 1, + 1, null, + 1, + null + ] + }, + "/myapp/app/models/contract.rb": { + "lines": [ null, null, + 1, + 1, + 1, + 1, + null + ] + }, + "/myapp/app/models/pool.rb": { + "lines": [ null, null, + 1, + 1, + null + ] + }, + "/myapp/app/models/signature.rb": { + "lines": [ null, null, + 1, + 1, + 1, + 1, + 1, null, null, null, null, + null + ] + }, + "/myapp/app/models/ticket.rb": { + "lines": [ null, null, + 1, + 1, + 1, + 1, + 1, + 1, null, + 1, + null + ] + }, + "/myapp/app/models/transaction.rb": { + "lines": [ null, - 0, null, - 0, - 0, - 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, null, + 1, + 2, null, null, + 1, + 2, null, null, + 1, + 42, null, + null + ] + }, + "/myapp/app/models/concerns/wallet_exists_validator.rb": { + "lines": [ null, - 0, - 0, - 0, null, + 1, + 1, + 52, + 13, null, null, + 52, + 13, null, null, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/sessions_controller.rb": { + "/myapp/app/models/wallet.rb": { "lines": [ null, null, - 0, + 1, + 1, null, + 1, + 1, + 1, null, + 1, null, + 1, null, null, + 1, null, + 1, + 59, + 57, + 57, null, null, + 59, + 59, null, + 59, + 1, null, + 58, + 58, null, null, + null + ] + }, + "/myapp/lib/osbc/osbc.rb": { + "lines": [ null, null, + 1, + 1, + 1, null, null, + 1, + null + ] + }, + "/myapp/lib/outerspace/blockchain.rb": { + "lines": [ null, null, + 1, null, + 1, + 1, + 1, null, null, + null + ] + }, + "/myapp/lib/outerspace/blockchain/version.rb": { + "lines": [ null, null, - 0 - ], - "branches": { - } + 1, + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/users/unlocks_controller.rb": { + "/myapp/app/controllers/api/v1/block_confirmations_controller.rb": { "lines": [ null, null, - 0, + 1, + 1, + 5, + 4, + 4, + 3, + 3, + 2, + 1, null, null, null, @@ -927,674 +782,821 @@ null, null, null, + 1, + 3, + 1, + 1, + 1, + 1, null, null, + 1, + 1, + 8, + 8, + 8, + 8, + 6, null, null, + 1, + 3, null, null, + 1, + 1, null, null, + 1, + 1, null, null, + 1, + 1, + 1, null, null, + 1, + 1, null, null, - 0 - ], - "branches": { - } + 1, + 3, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/controllers/wallets_controller.rb": { + "/myapp/app/controllers/blocks_controller.rb": { "lines": [ null, null, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/mailers/application_mailer.rb": { - "lines": [ null, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/acceptable_number_sequence.rb": { - "lines": [ + 1, null, null, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/acceptable_symbol_sequence.rb": { - "lines": [ + 1, null, + 1, + 1, null, - 0, - 0 - ], - "branches": { - } + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/acceptable_word.rb": { + "/myapp/app/controllers/chains_controller.rb": { "lines": [ null, null, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/block.rb": { - "lines": [ + 1, + 1, null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/chain.rb": { - "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, + 1, null, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/concerns/sequences_validator.rb": { - "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/concerns/wallet_exists_validator.rb": { - "lines": [ null, + 1, + 4, null, - 0, - 0, - 0, - 0, - 0, + 4, + 4, + 4, + 2, null, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/contract.rb": { - "lines": [ + 4, + 2, null, null, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/pool.rb": { - "lines": [ null, null, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/signature.rb": { - "lines": [ null, + 1, + 3, + 3, + 4, + 2, null, - 0, - 0, - 0, - 0, - 0, + 2, + 1, null, null, null, null, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/ticket.rb": { - "lines": [ null, + 1, + 2, null, - 0, - 0, - 0, - 0, - 0, - 0, + 2, + 4, + 2, null, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/transaction.rb": { - "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, null, - 0, - 0, - 0, + 1, + 7, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null, + 1, + 7, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/models/wallet.rb": { + "/myapp/app/controllers/contracts_controller.rb": { "lines": [ null, null, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, null, - 0, + 1, + 1, null, - 0, null, null, - 0, + 1, null, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, + 1, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "branches": { - } + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/services/application_service.rb": { + "/myapp/app/controllers/pools_controller.rb": { "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, + 1, 0, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null, + null, + 1, + null, + null, + 1, + null, + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/services/assign_contracts_service.rb": { + "/myapp/app/controllers/signatures_controller.rb": { "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, null, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0, + null + ] + }, + "/myapp/app/controllers/tickets_controller.rb": { + "lines": [ null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, + 1, 0, null, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, + 1, 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, + 1, 0, 0, 0, null, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, + 1, + 1, 0, null, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, + 1, + 1, + null, null, + 1, 0, + null, + null, + 1, 0, + null, + null, + null, + 1, 0, + null, + null + ] + }, + "/myapp/app/services/application_service.rb": { + "lines": [ + null, + null, + 1, + 1, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, 0, + null, + null, + 1, + 12, + null, + null, + 1, + 1, + null, + null + ] + }, + "/myapp/app/services/assign_contracts_service.rb": { + "lines": [ + null, + null, + 1, + 1, + 11, + 11, + null, + null, + 1, + 11, + null, + null, + 1, + 1, + null, + 1, + 236, + null, + null, + 1, + 22, + null, + null, + 1, + 184, + null, + null, + 1, + 150, + null, + null, + 1, + 10, + null, + null, + 1, + 300, + null, + null, + 1, + 2, + null, + null, + null, + null, + 1, + 12, + 2, + 2, + 2, + 2, + 2, + 2, + null, + null, + 1, + 77, + null, + null, + 1, + 75, + null, + null, + 1, + 86, + null, + null, + 1, + 2, + null, + null, + 1, + 75, + null, + null, + 1, + 87, + null, + null, + 1, + 2, + 2, + 2, + 2, + 20, + 10, + 10, + 10, + 10, + null, + 20, + 20, + 20, + null, + null, + 2, + null, + null, + 1, + 4, + null, + null, + 1, + 2, + 2, + 2, + 2, + 2, + 10, + 10, + 10, + 2, + 2, + null, + 8, + null, + null, + 2, + 2, + 2, + 2, + 2, + null, + null, + null, + 1, + 75, + 75, + null, + null, + 1, + 75, + 75, + null, + null, + 1, + 75, + 75, + 75, + null, + null, + 1, + 75, + 75, + null, + null, + 1, + 11, + 11, + null, + null, + 1, + 11, + 75, + 75, + null, + 11, + 11, + 75, + null, + null, + null + ] + }, + "/myapp/app/services/create_wallet_service.rb": { + "lines": [ + null, + null, + 1, + 1, + 2, + null, + null, + null, + 1, + 2, + 2, + null, + null, + 1, + 1, + null, + 1, + 2, + null, + null + ] + }, + "/myapp/app/services/transaction_to_block_service.rb": { + "lines": [ + null, + null, + 1, + 1, + 3, + 3, + 3, + 3, + null, + null, + 1, + 3, + null, + null, + 1, + 1, + null, + 1, + 4, + 3, + 2, + 2, + 2, + 2, + null, + 1, + 1, + null, + null, + null, + 1, + 11, + null, + null, + 1, + 4, + null, + null, + 1, + 2, + null, + null, + 1, + 6, + null, + null, + 1, + 3, + null, + null, + 1, + 2, + null, + null, + 1, + 4, + null, + null, + 1, + 1, + null, + null + ] + }, + "/myapp/lib/tasks/task_helpers/compose_taskhelper.rb": { + "lines": [ + null, + null, + 1, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + null, + 1, 0, + null, + null + ] + }, + "/myapp/lib/tasks/task_helpers/taskhelper.rb": { + "lines": [ + null, + null, + 1, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, + 1, 0, 0, 0, + null, + null, + null, + 1, 0, + null, + null, + null + ] + }, + "/myapp/app/workers/application_worker.rb": { + "lines": [ + null, + null, + 1, + 1, + 1, + null, + 1, + 1, + 3, + null, + null, + null, + 1, + 1, + 1, + null, + null, + null, + 1, + 1, + 2, + null, + null, + null, + 1, + 1, + 1, + null, + null, + null, + 1, + 1, + 2, + null, + null, + null, + 1, + null, + 1, + 4, + 1, + null, + null, + null, + 1, + 1, + null, + null, + 1, + 3, + null, + null, + 1, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, + 2, + null, + null, + 1, 0, - 0 - ], - "branches": { - } + null, + null, + 1, + 5, + null, + 1, + null, + null, + 1, + 10, + null, + null, + 1, + 1, + null, + null + ] + }, + "/myapp/app/workers/create_wallet_worker.rb": { + "lines": [ + null, + null, + null, + 1, + 1, + null, + 1, + 2, + 2, + 1, + 1, + null, + null, + null, + 1, + 1, + null, + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/services/create_ticket_service.rb": { + "/myapp/app/workers/transaction_to_block_worker.rb": { "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 5, + 5, + 5, + 5, + 5, null, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, null, - 0, - 0, - 0, + 1, + 5, + 4, + 3, + 1, + 1, + 1, null, - 0, - 0, - 0, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 4, null, - 0, - 0, - 0, null, - 0, - 0, - 0, + 1, + 1, + 1, null, - 0, - 0, - 0, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 5, null, - 0, - 0, - 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 1, + 3, + 3, null, - 0, - 0, - 0, - 0 - ], - "branches": { - } + null, + 1, + 1, + null, + null + ] }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/services/create_wallet_service.rb": { + "/myapp/app/workers/assign_contract_worker.rb": { "lines": [ null, null, - 0, - 0, + 1, + 1, 0, 0, null, null, - 0, - 0, - 0, - 0, + 1, + 1, null, - 0, + 1, 0, null, + null, + 1, 0, - 0, - 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/services/transaction_to_block_service.rb": { - "lines": [ null, null, - 0, - 0, - 0, - 0, - 0, - 0, + 1, 0, null, - 0, - 0, - 0, null, - 0, + 1, 0, null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + null + ] + }, + "/myapp/app/models/concerns/sequences_validator.rb": { + "lines": [ + null, null, 0, 0, 0, - null, - 0, 0, 0, - null, 0, 0, 0, null, 0, 0, - 0, null, 0, 0, @@ -1616,52 +1618,13 @@ "branches": { } }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/workers/application_worker.rb": { + "/myapp/app/services/create_ticket_service.rb": { "lines": [ null, null, 0, 0, 0, - null, - 0, - 0, - 0, - 0, - 0, - null, - 0, - 0, - 0, - 0, - 0, - null, - 0, - 0, - 0, - 0, - 0, - null, - 0, - 0, - 0, - 0, - 0, - null, - 0, - 0, - 0, - 0, - 0, - null, - 0, - null, - 0, - 0, - 0, - 0, - 0, - null, 0, 0, 0, @@ -1669,7 +1632,6 @@ 0, 0, 0, - null, 0, 0, 0, @@ -1680,7 +1642,6 @@ null, 0, 0, - 0, null, 0, 0, @@ -1689,8 +1650,6 @@ 0, 0, 0, - 0, - 0, null, 0, 0, @@ -1699,23 +1658,10 @@ 0, 0, 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/workers/assign_contract_worker.rb": { - "lines": [ - null, null, 0, 0, 0, - 0, - 0, - null, - 0, - 0, null, 0, 0, @@ -1728,19 +1674,9 @@ 0, 0, 0, - null, 0, 0, 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/workers/create_ticket_worker.rb": { - "lines": [ - null, - null, 0, 0, null, @@ -1753,26 +1689,10 @@ 0, 0, 0, - 0, - null, - 0, - 0, null, 0, 0, 0, - 0 - ], - "branches": { - } - }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/workers/create_wallet_worker.rb": { - "lines": [ - null, - null, - null, - 0, - 0, null, 0, 0, @@ -1781,8 +1701,6 @@ 0, 0, 0, - null, - 0, 0, null, 0, @@ -1793,7 +1711,7 @@ "branches": { } }, - "/home/jesusgautamah/Projects/outerspace-blockchain/app/workers/transaction_to_block_worker.rb": { + "/myapp/app/workers/create_ticket_worker.rb": { "lines": [ null, null, @@ -1807,37 +1725,12 @@ 0, 0, 0, - null, - 0, - 0, - null, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - null, - 0, - 0, - 0, - null, - 0, - 0, - 0, - 0, - null, 0, 0, 0, null, 0, 0, - 0, - 0, null, 0, 0, @@ -1848,6 +1741,6 @@ } } }, - "timestamp": 1668993590 + "timestamp": 1669310702 } } diff --git a/coverage/index.html b/coverage/index.html index 2f269f6..66973e4 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -1,11 +1,11 @@ - Code coverage for Outerspace-blockchain + Code coverage for Myapp - + @@ -14,7 +14,7 @@ loading
-
Generated 2022-11-20T22:19:51-03:00
+
Generated 2022-11-24T17:25:02+00:00
@@ -22,15 +22,15 @@

All Files ( - - 3.75% + + 80.91% covered at - - 0.04 + + 7.15 hits/line ) @@ -39,15 +39,15 @@

- 54 files in total. + 56 files in total.
- 987 relevant lines, - 37 lines covered and - 950 lines missed. - ( - 3.75% + 728 relevant lines, + 589 lines covered and + 139 lines missed. + ( + 80.91% )
@@ -71,183 +71,183 @@

- app/controllers/api/v1/block_confirmations_controller.rb - 0.00 % + app/controllers/api/v1/block_confirmations_controller.rb + 100.00 % 65 - 54 + 35 + 35 0 - 54 - 0.00 + 2.54 - app/controllers/application_controller.rb - 0.00 % + app/controllers/application_controller.rb + 89.47 % 72 - 52 - 0 - 52 - 0.00 + 38 + 34 + 4 + 11.71 - app/controllers/blocks_controller.rb - 0.00 % + app/controllers/blocks_controller.rb + 100.00 % 20 - 12 + 8 + 8 0 - 12 - 0.00 + 1.00 - app/controllers/chains_controller.rb - 0.00 % + app/controllers/chains_controller.rb + 100.00 % 72 - 50 + 33 + 33 0 - 50 - 0.00 + 2.33 - app/controllers/contracts_controller.rb - 0.00 % - 25 - 15 + app/controllers/contracts_controller.rb + 100.00 % + 20 + 8 + 8 0 - 15 - 0.00 + 1.00 - app/controllers/pools_controller.rb - 0.00 % - 73 - 51 - 0 - 51 - 0.00 + app/controllers/pools_controller.rb + 88.89 % + 21 + 9 + 8 + 1 + 0.89 - app/controllers/signatures_controller.rb - 0.00 % - 25 - 15 + app/controllers/signatures_controller.rb + 100.00 % + 20 + 8 + 8 0 - 15 - 0.00 + 1.00 - app/controllers/tickets_controller.rb - 0.00 % - 76 - 53 - 0 - 53 - 0.00 + app/controllers/tickets_controller.rb + 60.87 % + 49 + 23 + 14 + 9 + 0.61 - app/controllers/transactions_controller.rb - 0.00 % + app/controllers/transactions_controller.rb + 100.00 % 48 - 33 + 24 + 24 0 - 33 - 0.00 + 1.08 - app/controllers/users/confirmations_controller.rb - 0.00 % + app/controllers/users/confirmations_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/omniauth_callbacks_controller.rb - 0.00 % + app/controllers/users/omniauth_callbacks_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/passwords_controller.rb - 0.00 % + app/controllers/users/passwords_controller.rb + 100.00 % 34 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/registrations_controller.rb - 0.00 % + app/controllers/users/registrations_controller.rb + 100.00 % 61 - 13 + 9 + 9 0 - 13 - 0.00 + 1.00 - app/controllers/users/sessions_controller.rb - 0.00 % + app/controllers/users/sessions_controller.rb + 100.00 % 27 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/unlocks_controller.rb - 0.00 % + app/controllers/users/unlocks_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/wallets_controller.rb - 0.00 % + app/controllers/wallets_controller.rb + 100.00 % 18 - 13 + 9 + 9 0 - 13 - 0.00 + 1.11 - app/helpers/application_helper.rb + app/helpers/application_helper.rb 100.00 % 4 1 @@ -258,7 +258,7 @@

- app/helpers/blocks_helper.rb + app/helpers/blocks_helper.rb 100.00 % 4 1 @@ -269,7 +269,7 @@

- app/helpers/chains_helper.rb + app/helpers/chains_helper.rb 100.00 % 4 1 @@ -280,7 +280,7 @@

- app/helpers/contracts_helper.rb + app/helpers/contracts_helper.rb 100.00 % 4 1 @@ -291,7 +291,7 @@

- app/helpers/pools_helper.rb + app/helpers/pools_helper.rb 100.00 % 4 1 @@ -302,7 +302,7 @@

- app/helpers/signatures_helper.rb + app/helpers/signatures_helper.rb 100.00 % 4 1 @@ -313,7 +313,7 @@

- app/helpers/tickets_helper.rb + app/helpers/tickets_helper.rb 100.00 % 4 1 @@ -324,7 +324,7 @@

- app/helpers/transactions_helper.rb + app/helpers/transactions_helper.rb 100.00 % 4 1 @@ -335,7 +335,7 @@

- app/helpers/wallets_helper.rb + app/helpers/wallets_helper.rb 100.00 % 4 1 @@ -346,51 +346,51 @@

- app/mailers/application_mailer.rb - 0.00 % + app/mailers/application_mailer.rb + 100.00 % 6 - 4 + 3 + 3 0 - 4 - 0.00 + 1.00 - app/models/acceptable_number_sequence.rb - 0.00 % + app/models/acceptable_number_sequence.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/acceptable_symbol_sequence.rb - 0.00 % + app/models/acceptable_symbol_sequence.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/acceptable_word.rb - 0.00 % + app/models/acceptable_word.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/application_record.rb + app/models/application_record.rb 100.00 % 5 2 @@ -401,29 +401,29 @@

- app/models/block.rb - 0.00 % + app/models/block.rb + 100.00 % 17 - 14 + 12 + 12 0 - 14 - 0.00 + 6.58 - app/models/chain.rb - 0.00 % + app/models/chain.rb + 100.00 % 10 - 7 + 6 + 6 0 - 7 - 0.00 + 1.00 - app/models/concerns/sequences_validator.rb + app/models/concerns/sequences_validator.rb 0.00 % 30 23 @@ -434,172 +434,172 @@

- app/models/concerns/wallet_exists_validator.rb - 0.00 % + app/models/concerns/wallet_exists_validator.rb + 100.00 % 13 - 10 + 6 + 6 0 - 10 - 0.00 + 22.00 - app/models/contract.rb - 0.00 % + app/models/contract.rb + 100.00 % 7 - 5 + 4 + 4 0 - 5 - 0.00 + 1.00 - app/models/pool.rb - 0.00 % + app/models/pool.rb + 100.00 % 5 - 3 + 2 + 2 0 - 3 - 0.00 + 1.00 - app/models/signature.rb - 0.00 % + app/models/signature.rb + 100.00 % 12 - 6 + 5 + 5 0 - 6 - 0.00 + 1.00 - app/models/ticket.rb - 0.00 % + app/models/ticket.rb + 100.00 % 11 - 8 + 7 + 7 0 - 8 - 0.00 + 1.00 - app/models/transaction.rb - 0.00 % + app/models/transaction.rb + 100.00 % 25 - 20 + 16 + 16 0 - 20 - 0.00 + 3.69 - app/models/user.rb - 55.56 % + app/models/user.rb + 100.00 % 44 27 - 15 - 12 - 0.56 + 27 + 0 + 32.11 - app/models/wallet.rb - 0.00 % + app/models/wallet.rb + 100.00 % 33 - 23 + 18 + 18 0 - 23 - 0.00 + 26.44 - app/services/application_service.rb - 0.00 % + app/services/application_service.rb + 91.67 % 23 - 18 - 0 - 18 - 0.00 + 12 + 11 + 1 + 1.83 - app/services/assign_contracts_service.rb - 0.00 % - 163 - 134 + app/services/assign_contracts_service.rb + 100.00 % + 162 + 98 + 98 0 - 134 - 0.00 + 25.94 - app/services/create_ticket_service.rb + app/services/create_ticket_service.rb 0.00 % - 83 - 67 + 87 + 71 0 - 67 + 71 0.00 - app/services/create_wallet_service.rb - 0.00 % + app/services/create_wallet_service.rb + 100.00 % 20 - 14 + 10 + 10 0 - 14 - 0.00 + 1.40 - app/services/transaction_to_block_service.rb - 0.00 % + app/services/transaction_to_block_service.rb + 100.00 % 62 - 49 + 35 + 35 0 - 49 - 0.00 + 2.26 - app/workers/application_worker.rb - 0.00 % + app/workers/application_worker.rb + 97.62 % 82 - 65 - 0 - 65 - 0.00 + 42 + 41 + 1 + 1.52 - app/workers/assign_contract_worker.rb - 0.00 % + app/workers/assign_contract_worker.rb + 57.14 % 27 - 20 - 0 - 20 - 0.00 + 14 + 8 + 6 + 0.57 - app/workers/create_ticket_worker.rb + app/workers/create_ticket_worker.rb 0.00 % 23 18 @@ -610,29 +610,29 @@

- app/workers/create_wallet_worker.rb - 0.00 % + app/workers/create_wallet_worker.rb + 100.00 % 21 - 15 + 11 + 11 0 - 15 - 0.00 + 1.18 - app/workers/transaction_to_block_worker.rb - 0.00 % + app/workers/transaction_to_block_worker.rb + 100.00 % 48 - 38 + 29 + 29 0 - 38 - 0.00 + 2.38 - lib/osbc/osbc.rb + lib/osbc/osbc.rb 100.00 % 9 4 @@ -643,7 +643,7 @@

- lib/outerspace/blockchain.rb + lib/outerspace/blockchain.rb 100.00 % 10 4 @@ -654,7 +654,7 @@

- lib/outerspace/blockchain/version.rb + lib/outerspace/blockchain/version.rb 100.00 % 7 3 @@ -664,6 +664,28 @@

+ + lib/tasks/task_helpers/compose_taskhelper.rb + 92.31 % + 22 + 13 + 12 + 1 + 1.08 + + + + + lib/tasks/task_helpers/taskhelper.rb + 66.67 % + 23 + 12 + 8 + 4 + 0.67 + + +

@@ -675,15 +697,15 @@

Controllers ( - - 0.0% + + 93.3% covered at - - 0.0 + + 3.38 hits/line ) @@ -696,11 +718,11 @@

- 371 relevant lines, - 0 lines covered and - 371 lines missed. - ( - 0.0% + 209 relevant lines, + 195 lines covered and + 14 lines missed. + ( + 93.3% )
@@ -724,178 +746,178 @@

- app/controllers/api/v1/block_confirmations_controller.rb - 0.00 % + app/controllers/api/v1/block_confirmations_controller.rb + 100.00 % 65 - 54 + 35 + 35 0 - 54 - 0.00 + 2.54 - app/controllers/application_controller.rb - 0.00 % + app/controllers/application_controller.rb + 89.47 % 72 - 52 - 0 - 52 - 0.00 + 38 + 34 + 4 + 11.71 - app/controllers/blocks_controller.rb - 0.00 % + app/controllers/blocks_controller.rb + 100.00 % 20 - 12 + 8 + 8 0 - 12 - 0.00 + 1.00 - app/controllers/chains_controller.rb - 0.00 % + app/controllers/chains_controller.rb + 100.00 % 72 - 50 + 33 + 33 0 - 50 - 0.00 + 2.33 - app/controllers/contracts_controller.rb - 0.00 % - 25 - 15 + app/controllers/contracts_controller.rb + 100.00 % + 20 + 8 + 8 0 - 15 - 0.00 + 1.00 - app/controllers/pools_controller.rb - 0.00 % - 73 - 51 - 0 - 51 - 0.00 + app/controllers/pools_controller.rb + 88.89 % + 21 + 9 + 8 + 1 + 0.89 - app/controllers/signatures_controller.rb - 0.00 % - 25 - 15 + app/controllers/signatures_controller.rb + 100.00 % + 20 + 8 + 8 0 - 15 - 0.00 + 1.00 - app/controllers/tickets_controller.rb - 0.00 % - 76 - 53 - 0 - 53 - 0.00 + app/controllers/tickets_controller.rb + 60.87 % + 49 + 23 + 14 + 9 + 0.61 - app/controllers/transactions_controller.rb - 0.00 % + app/controllers/transactions_controller.rb + 100.00 % 48 - 33 + 24 + 24 0 - 33 - 0.00 + 1.08 - app/controllers/users/confirmations_controller.rb - 0.00 % + app/controllers/users/confirmations_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/omniauth_callbacks_controller.rb - 0.00 % + app/controllers/users/omniauth_callbacks_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/passwords_controller.rb - 0.00 % + app/controllers/users/passwords_controller.rb + 100.00 % 34 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/registrations_controller.rb - 0.00 % + app/controllers/users/registrations_controller.rb + 100.00 % 61 - 13 + 9 + 9 0 - 13 - 0.00 + 1.00 - app/controllers/users/sessions_controller.rb - 0.00 % + app/controllers/users/sessions_controller.rb + 100.00 % 27 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/users/unlocks_controller.rb - 0.00 % + app/controllers/users/unlocks_controller.rb + 100.00 % 30 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/controllers/wallets_controller.rb - 0.00 % + app/controllers/wallets_controller.rb + 100.00 % 18 - 13 + 9 + 9 0 - 13 - 0.00 + 1.11 @@ -967,15 +989,15 @@

Models ( - - 11.04% + + 82.44% covered at - - 0.11 + + 12.53 hits/line ) @@ -988,11 +1010,11 @@

- 154 relevant lines, - 17 lines covered and - 137 lines missed. - ( - 11.04% + 131 relevant lines, + 108 lines covered and + 23 lines missed. + ( + 82.44% )
@@ -1016,40 +1038,40 @@

- app/models/acceptable_number_sequence.rb - 0.00 % + app/models/acceptable_number_sequence.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/acceptable_symbol_sequence.rb - 0.00 % + app/models/acceptable_symbol_sequence.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/acceptable_word.rb - 0.00 % + app/models/acceptable_word.rb + 100.00 % 4 - 2 + 1 + 1 0 - 2 - 0.00 + 1.00 - app/models/application_record.rb + app/models/application_record.rb 100.00 % 5 2 @@ -1060,29 +1082,29 @@

- app/models/block.rb - 0.00 % + app/models/block.rb + 100.00 % 17 - 14 + 12 + 12 0 - 14 - 0.00 + 6.58 - app/models/chain.rb - 0.00 % + app/models/chain.rb + 100.00 % 10 - 7 + 6 + 6 0 - 7 - 0.00 + 1.00 - app/models/concerns/sequences_validator.rb + app/models/concerns/sequences_validator.rb 0.00 % 30 23 @@ -1093,90 +1115,90 @@

- app/models/concerns/wallet_exists_validator.rb - 0.00 % + app/models/concerns/wallet_exists_validator.rb + 100.00 % 13 - 10 + 6 + 6 0 - 10 - 0.00 + 22.00 - app/models/contract.rb - 0.00 % + app/models/contract.rb + 100.00 % 7 - 5 + 4 + 4 0 - 5 - 0.00 + 1.00 - app/models/pool.rb - 0.00 % + app/models/pool.rb + 100.00 % 5 - 3 + 2 + 2 0 - 3 - 0.00 + 1.00 - app/models/signature.rb - 0.00 % + app/models/signature.rb + 100.00 % 12 - 6 + 5 + 5 0 - 6 - 0.00 + 1.00 - app/models/ticket.rb - 0.00 % + app/models/ticket.rb + 100.00 % 11 - 8 + 7 + 7 0 - 8 - 0.00 + 1.00 - app/models/transaction.rb - 0.00 % + app/models/transaction.rb + 100.00 % 25 - 20 + 16 + 16 0 - 20 - 0.00 + 3.69 - app/models/user.rb - 55.56 % + app/models/user.rb + 100.00 % 44 27 - 15 - 12 - 0.56 + 27 + 0 + 32.11 - app/models/wallet.rb - 0.00 % + app/models/wallet.rb + 100.00 % 33 - 23 + 18 + 18 0 - 23 - 0.00 + 26.44 @@ -1190,15 +1212,15 @@

Mailers ( - - 0.0% + + 100.0% covered at - - 0.0 + + 1.0 hits/line ) @@ -1211,11 +1233,11 @@

- 4 relevant lines, - 0 lines covered and - 4 lines missed. - ( - 0.0% + 3 relevant lines, + 3 lines covered and + 0 lines missed. + ( + 100.0% )
@@ -1239,13 +1261,13 @@

- app/mailers/application_mailer.rb - 0.00 % + app/mailers/application_mailer.rb + 100.00 % 6 - 4 + 3 + 3 0 - 4 - 0.00 + 1.00 @@ -1308,7 +1330,7 @@

- app/helpers/application_helper.rb + app/helpers/application_helper.rb 100.00 % 4 1 @@ -1319,7 +1341,7 @@

- app/helpers/blocks_helper.rb + app/helpers/blocks_helper.rb 100.00 % 4 1 @@ -1330,7 +1352,7 @@

- app/helpers/chains_helper.rb + app/helpers/chains_helper.rb 100.00 % 4 1 @@ -1341,7 +1363,7 @@

- app/helpers/contracts_helper.rb + app/helpers/contracts_helper.rb 100.00 % 4 1 @@ -1352,7 +1374,7 @@

- app/helpers/pools_helper.rb + app/helpers/pools_helper.rb 100.00 % 4 1 @@ -1363,7 +1385,7 @@

- app/helpers/signatures_helper.rb + app/helpers/signatures_helper.rb 100.00 % 4 1 @@ -1374,7 +1396,7 @@

- app/helpers/tickets_helper.rb + app/helpers/tickets_helper.rb 100.00 % 4 1 @@ -1385,7 +1407,7 @@

- app/helpers/transactions_helper.rb + app/helpers/transactions_helper.rb 100.00 % 4 1 @@ -1396,7 +1418,7 @@

- app/helpers/wallets_helper.rb + app/helpers/wallets_helper.rb 100.00 % 4 1 @@ -1417,14 +1439,14 @@

Jobs ( - 0.0% + 78.07% covered at - - 0.0 + + 1.35 hits/line ) @@ -1437,11 +1459,11 @@

- 156 relevant lines, - 0 lines covered and - 156 lines missed. + 114 relevant lines, + 89 lines covered and + 25 lines missed. ( - 0.0% + 78.07% )
@@ -1465,29 +1487,29 @@

- app/workers/application_worker.rb - 0.00 % + app/workers/application_worker.rb + 97.62 % 82 - 65 - 0 - 65 - 0.00 + 42 + 41 + 1 + 1.52 - app/workers/assign_contract_worker.rb - 0.00 % + app/workers/assign_contract_worker.rb + 57.14 % 27 - 20 - 0 - 20 - 0.00 + 14 + 8 + 6 + 0.57 - app/workers/create_ticket_worker.rb + app/workers/create_ticket_worker.rb 0.00 % 23 18 @@ -1498,24 +1520,24 @@

- app/workers/create_wallet_worker.rb - 0.00 % + app/workers/create_wallet_worker.rb + 100.00 % 21 - 15 + 11 + 11 0 - 15 - 0.00 + 1.18 - app/workers/transaction_to_block_worker.rb - 0.00 % + app/workers/transaction_to_block_worker.rb + 100.00 % 48 - 38 + 29 + 29 0 - 38 - 0.00 + 2.38 @@ -1529,15 +1551,15 @@

Libraries ( - - 100.0% + + 86.11% covered at - - 1.0 + + 0.92 hits/line ) @@ -1546,15 +1568,15 @@

- 3 files in total. + 5 files in total.
- 11 relevant lines, - 11 lines covered and - 0 lines missed. - ( - 100.0% + 36 relevant lines, + 31 lines covered and + 5 lines missed. + ( + 86.11% )
@@ -1578,7 +1600,7 @@

- lib/osbc/osbc.rb + lib/osbc/osbc.rb 100.00 % 9 4 @@ -1589,7 +1611,7 @@

- lib/outerspace/blockchain.rb + lib/outerspace/blockchain.rb 100.00 % 10 4 @@ -1600,7 +1622,7 @@

- lib/outerspace/blockchain/version.rb + lib/outerspace/blockchain/version.rb 100.00 % 7 3 @@ -1610,6 +1632,28 @@

+ + lib/tasks/task_helpers/compose_taskhelper.rb + 92.31 % + 22 + 13 + 12 + 1 + 1.08 + + + + + lib/tasks/task_helpers/taskhelper.rb + 66.67 % + 23 + 12 + 8 + 4 + 0.67 + + + @@ -1621,14 +1665,14 @@

Services ( - 0.0% + 68.14% covered at - - 0.0 + + 11.76 hits/line ) @@ -1641,11 +1685,11 @@

- 282 relevant lines, - 0 lines covered and - 282 lines missed. + 226 relevant lines, + 154 lines covered and + 72 lines missed. ( - 0.0% + 68.14% )
@@ -1669,57 +1713,57 @@

- app/services/application_service.rb - 0.00 % + app/services/application_service.rb + 91.67 % 23 - 18 - 0 - 18 - 0.00 + 12 + 11 + 1 + 1.83 - app/services/assign_contracts_service.rb - 0.00 % - 163 - 134 + app/services/assign_contracts_service.rb + 100.00 % + 162 + 98 + 98 0 - 134 - 0.00 + 25.94 - app/services/create_ticket_service.rb + app/services/create_ticket_service.rb 0.00 % - 83 - 67 + 87 + 71 0 - 67 + 71 0.00 - app/services/create_wallet_service.rb - 0.00 % + app/services/create_wallet_service.rb + 100.00 % 20 - 14 + 10 + 10 0 - 14 - 0.00 + 1.40 - app/services/transaction_to_block_service.rb - 0.00 % + app/services/transaction_to_block_service.rb + 100.00 % 62 - 49 + 35 + 35 0 - 49 - 0.00 + 2.26 @@ -1734,14 +1778,14 @@

Workers ( - 0.0% + 78.07% covered at - - 0.0 + + 1.35 hits/line ) @@ -1754,11 +1798,11 @@

- 156 relevant lines, - 0 lines covered and - 156 lines missed. + 114 relevant lines, + 89 lines covered and + 25 lines missed. ( - 0.0% + 78.07% )
@@ -1782,29 +1826,29 @@

- app/workers/application_worker.rb - 0.00 % + app/workers/application_worker.rb + 97.62 % 82 - 65 - 0 - 65 - 0.00 + 42 + 41 + 1 + 1.52 - app/workers/assign_contract_worker.rb - 0.00 % + app/workers/assign_contract_worker.rb + 57.14 % 27 - 20 - 0 - 20 - 0.00 + 14 + 8 + 6 + 0.57 - app/workers/create_ticket_worker.rb + app/workers/create_ticket_worker.rb 0.00 % 23 18 @@ -1815,24 +1859,24 @@

- app/workers/create_wallet_worker.rb - 0.00 % + app/workers/create_wallet_worker.rb + 100.00 % 21 - 15 + 11 + 11 0 - 15 - 0.00 + 1.18 - app/workers/transaction_to_block_worker.rb - 0.00 % + app/workers/transaction_to_block_worker.rb + 100.00 % 48 - 38 + 29 + 29 0 - 38 - 0.00 + 2.38 @@ -1895,7 +1939,7 @@

- lib/osbc/osbc.rb + lib/osbc/osbc.rb 100.00 % 9 4 @@ -1964,7 +2008,7 @@

- lib/outerspace/blockchain.rb + lib/outerspace/blockchain.rb 100.00 % 10 4 @@ -1975,7 +2019,7 @@

- lib/outerspace/blockchain/version.rb + lib/outerspace/blockchain/version.rb 100.00 % 7 3 @@ -1991,6 +2035,86 @@

+
+

+ Task Helpers + ( + + 80.0% + + + + covered at + + + 0.88 + + hits/line + ) +

+ + + +
+ 2 files in total. +
+ +
+ 25 relevant lines, + 20 lines covered and + 5 lines missed. + ( + 80.0% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
lib/tasks/task_helpers/compose_taskhelper.rb92.31 %22131211.08
lib/tasks/task_helpers/taskhelper.rb66.67 %2312840.67
+
+
+ + + +
+    
    -
  1. +
  2. - + # frozen_string_literal: true
  3. -
  4. +
  5. - # protected +
  6. -
  7. - +
  8. + 1 - + class Users::RegistrationsController < Devise::RegistrationsController
  9. -
  10. - +
  11. + 1 - # The path used after resending confirmation instructions. + before_action :configure_sign_up_params, only: [:create]
  12. -
  13. +
  14. - # def after_resending_confirmation_instructions_path_for(resource_name) + # before_action :configure_account_update_params, only: [:update]
  15. -
  16. +
  17. - # super(resource_name) +
  18. -
  19. +
  20. - # end + # GET /resource/sign_up
  21. -
  22. +
  23. - + # def new
  24. -
  25. +
  26. - # The path used after confirmation. + # super
  27. -
  28. +
  29. - # def after_confirmation_path_for(resource_name, resource) + # end
  30. -
  31. +
  32. - # super(resource_name, resource) +
  33. -
  34. +
  35. - # end + # POST /resource
  36. -
  37. - +
  38. + 1 - end + def create
  39. -
-
- - - -
-
-

app/controllers/users/omniauth_callbacks_controller.rb

-

- - 0.0% - - - lines covered -

- - - -
- 2 relevant lines. - 0 lines covered and - 2 lines missed. -
- - - -
- -
-    
    -
    -
  1. - +
  2. + 1 - # frozen_string_literal: true + super
  3. -
  4. +
  5. - + end
  6. -
  7. +
  8. - class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController +
  9. -
  10. +
  11. - # You should configure your model like this: + # GET /resource/edit
  12. -
  13. +
  14. - # devise :omniauthable, omniauth_providers: [:twitter] + # def edit
  15. -
  16. +
  17. - + # super
  18. -
  19. +
  20. - # You should also create an action method in this controller like this: + # end
  21. -
  22. +
  23. - # def twitter +
  24. -
  25. +
  26. - # end + # PUT /resource
  27. -
  28. +
  29. - + # def update
  30. -
  31. +
  32. - # More info at: + # super
  33. -
  34. +
  35. - # https://github.com/heartcombo/devise#omniauth + # end
  36. -
  37. +
  38. @@ -8047,29 +8101,29 @@

  39. -
  40. +
  41. - # GET|POST /resource/auth/twitter + # DELETE /resource
  42. -
  43. +
  44. - # def passthru + # def destroy
  45. -
  46. +
  47. @@ -8080,7 +8134,7 @@

  48. -
  49. +
  50. @@ -8091,7 +8145,7 @@

  51. -
  52. +
  53. @@ -8102,247 +8156,216 @@

  54. -
  55. +
  56. - # GET|POST /users/auth/twitter/callback + # GET /resource/cancel
  57. -
  58. +
  59. - # def failure + # Forces the session data which is usually expired after sign
  60. -
  61. +
  62. - # super + # in to be expired now. This is useful if the user wants to
  63. -
  64. +
  65. - # end + # cancel oauth signing in/up in the middle of the process,
  66. -
  67. +
  68. - + # removing all OAuth session data.
  69. -
  70. +
  71. - # protected + # def cancel
  72. -
  73. +
  74. - + # super
  75. -
  76. +
  77. - # The path used when OmniAuth fails + # end
  78. -
  79. +
  80. - # def after_omniauth_failure_path_for(scope) +
  81. -
  82. - +
  83. + 1 - # super(scope) + protected
  84. -
  85. +
  86. - # end + # If you have extra params to permit, append them to the sanitizer.
  87. -
  88. - +
  89. + 1 - end + def configure_sign_up_params
  90. -
-
-
- - -
-
-

app/controllers/users/passwords_controller.rb

-

- - 0.0% - - - lines covered -

- - - -
- 2 relevant lines. - 0 lines covered and - 2 lines missed. -
- - - -
- -
-    
    -
    -
  1. - +
  2. + 1 - # frozen_string_literal: true + devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
  3. -
  4. +
  5. - + end
  6. -
  7. +
  8. - class Users::PasswordsController < Devise::PasswordsController +
  9. -
  10. +
  11. - # GET /resource/password/new + # If you have extra params to permit, append them to the sanitizer.
  12. -
  13. +
  14. - # def new + # def configure_account_update_params
  15. -
  16. +
  17. - # super + # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
  18. -
  19. +
  20. - # end + # end
  21. -
  22. +
  23. @@ -8353,51 +8376,51 @@

  24. -
  25. +
  26. - # POST /resource/password + # The path used after sign up.
  27. -
  28. - +
  29. + 1 - # def create + def after_sign_up_path_for(resource)
  30. -
  31. - +
  32. + 1 - # super + root_path
  33. -
  34. +
  35. - # end + end
  36. -
  37. +
  38. @@ -8408,40 +8431,40 @@

  39. -
  40. +
  41. - # GET /resource/password/edit?reset_password_token=abcdef + # The path used after sign up for inactive accounts.
  42. -
  43. +
  44. - # def edit + # def after_inactive_sign_up_path_for(resource)
  45. -
  46. +
  47. - # super + # super(resource)
  48. -
  49. +
  50. @@ -8452,62 +8475,93 @@

  51. -
  52. +
  53. - + end
  54. +
+
+
+ + +
+
+

app/controllers/users/sessions_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    +
    -
  1. +
  2. - # PUT /resource/password + # frozen_string_literal: true
  3. -
  4. +
  5. - # def update +
  6. -
  7. - +
  8. + 1 - # super + class Users::SessionsController < Devise::SessionsController
  9. -
  10. +
  11. - # end + # before_action :configure_sign_in_params, only: [:create]
  12. -
  13. +
  14. @@ -8518,214 +8572,183 @@

  15. -
  16. +
  17. - # protected + # GET /resource/sign_in
  18. -
  19. +
  20. - + # def new
  21. -
  22. +
  23. - # def after_resetting_password_path_for(resource) + # super
  24. -
  25. +
  26. - # super(resource) + # end
  27. -
  28. +
  29. - # end +
  30. -
  31. +
  32. - + # POST /resource/sign_in
  33. -
  34. +
  35. - # The path used after sending reset password instructions + # def create
  36. -
  37. +
  38. - # def after_sending_reset_password_instructions_path_for(resource_name) + # super
  39. -
  40. +
  41. - # super(resource_name) + # end
  42. -
  43. +
  44. - # end +
  45. -
  46. +
  47. - end + # DELETE /resource/sign_out
  48. -
-
-
- - -
-
-

app/controllers/users/registrations_controller.rb

-

- - 0.0% - - - lines covered -

- - - -
- 13 relevant lines. - 0 lines covered and - 13 lines missed. -
- - - -
- -
-    
    -
    -
  1. +
  2. - # frozen_string_literal: true + # def destroy
  3. -
  4. +
  5. - + # super
  6. -
  7. +
  8. - class Users::RegistrationsController < Devise::RegistrationsController + # end
  9. -
  10. +
  11. - before_action :configure_sign_up_params, only: [:create] +
  12. -
  13. +
  14. - # before_action :configure_account_update_params, only: [:update] + # protected
  15. -
  16. +
  17. @@ -8736,40 +8759,40 @@

  18. -
  19. +
  20. - # GET /resource/sign_up + # If you have extra params to permit, append them to the sanitizer.
  21. -
  22. +
  23. - # def new + # def configure_sign_in_params
  24. -
  25. +
  26. - # super + # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
  27. -
  28. +
  29. @@ -8780,95 +8803,104 @@

  30. -
  31. +
  32. - + end
  33. -
    -
  34. - - - - +
+
+
- # POST /resource - - -
-
  • - - +
    +
    +

    app/controllers/users/unlocks_controller.rb

    +

    + + 100.0% + - + lines covered +

    - def create -
  • -
    + + +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    + + + + + +
    +    
      -
    1. +
    2. - super + # frozen_string_literal: true
    3. -
    4. +
    5. - end +
    6. -
    7. - +
    8. + 1 - + class Users::UnlocksController < Devise::UnlocksController
    9. -
    10. +
    11. - # GET /resource/edit + # GET /resource/unlock/new
    12. -
    13. +
    14. - # def edit + # def new
    15. -
    16. +
    17. @@ -8879,7 +8911,7 @@

    18. -
    19. +
    20. @@ -8890,7 +8922,7 @@

    21. -
    22. +
    23. @@ -8901,29 +8933,29 @@

    24. -
    25. +
    26. - # PUT /resource + # POST /resource/unlock
    27. -
    28. +
    29. - # def update + # def create
    30. -
    31. +
    32. @@ -8934,7 +8966,7 @@

    33. -
    34. +
    35. @@ -8945,7 +8977,7 @@

    36. -
    37. +
    38. @@ -8956,29 +8988,29 @@

    39. -
    40. +
    41. - # DELETE /resource + # GET /resource/unlock?unlock_token=abcdef
    42. -
    43. +
    44. - # def destroy + # def show
    45. -
    46. +
    47. @@ -8989,7 +9021,7 @@

    48. -
    49. +
    50. @@ -9000,7 +9032,7 @@

    51. -
    52. +
    53. @@ -9011,271 +9043,302 @@

    54. -
    55. +
    56. - # GET /resource/cancel + # protected
    57. -
    58. +
    59. - # Forces the session data which is usually expired after sign +
    60. -
    61. +
    62. - # in to be expired now. This is useful if the user wants to + # The path used after sending unlock password instructions
    63. -
    64. +
    65. - # cancel oauth signing in/up in the middle of the process, + # def after_sending_unlock_instructions_path_for(resource)
    66. -
    67. +
    68. - # removing all OAuth session data. + # super(resource)
    69. -
    70. +
    71. - # def cancel + # end
    72. -
    73. +
    74. - # super +
    75. -
    76. +
    77. - # end + # The path used after unlocking the resource
    78. -
    79. +
    80. - + # def after_unlock_path_for(resource)
    81. -
    82. +
    83. - protected + # super(resource)
    84. -
    85. +
    86. - # If you have extra params to permit, append them to the sanitizer. + # end
    87. -
    88. +
    89. - def configure_sign_up_params + end
    90. +
    +
    + + + +
    +
    +

    app/controllers/wallets_controller.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 9 relevant lines. + 9 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) + # frozen_string_literal: true
    3. -
    4. +
    5. - end +
    6. -
    7. - +
    8. + 1 - + class WalletsController < ApplicationController
    9. -
    10. - +
    11. + 1 - # If you have extra params to permit, append them to the sanitizer. + before_action :set_wallet, only: %i[ show edit update destroy ]
    12. -
    13. - +
    14. + 1 - # def configure_account_update_params + before_action :authenticate_user!
    15. -
    16. +
    17. - # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) +
    18. -
    19. - +
    20. + 1 - # end + def index
    21. -
    22. - +
    23. + 2 - + @wallets = current_user.wallet
    24. -
    25. +
    26. - # The path used after sign up. + end
    27. -
    28. +
    29. - def after_sign_up_path_for(resource) +
    30. -
    31. - +
    32. + 1 - root_path + def show
    33. -
    34. +
    35. - end + end
    36. -
    37. +
    38. @@ -9286,51 +9349,51 @@

    39. -
    40. - +
    41. + 1 - # The path used after sign up for inactive accounts. + private
    42. -
    43. - +
    44. + 1 - # def after_inactive_sign_up_path_for(resource) + def set_wallet
    45. -
    46. - +
    47. + 1 - # super(resource) + @wallet = Wallet.find(params[:id])
    48. -
    49. +
    50. - # end + end
    51. -
    52. +
    53. @@ -9345,12 +9408,12 @@

    54. -
      +
      -

      app/controllers/users/sessions_controller.rb

      +

      app/helpers/application_helper.rb

      - - 0.0% + + 100.0% lines covered @@ -9359,9 +9422,9 @@

      - 2 relevant lines. - 0 lines covered and - 2 lines missed. + 1 relevant lines. + 1 lines covered and + 0 lines missed.
      @@ -9394,13 +9457,13 @@

      -
    55. - +
    56. + 1 - class Users::SessionsController < Devise::SessionsController + module ApplicationHelper
    57. @@ -9411,67 +9474,54 @@

      - # before_action :configure_sign_in_params, only: [:create] + end

      -
      -
    58. - - - - +
    +
    +
    - - - -
    -
  • - - +
    +
    +

    app/helpers/blocks_helper.rb

    +

    + + 100.0% + - + lines covered +

    - # GET /resource/sign_in -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - # def new -
  • -
    - -
    -
  • - - + - +
  • - # super - - +
    +    
      -
    1. +
    2. - # end + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -9482,128 +9532,71 @@

    6. -
    7. - - - - - - # POST /resource/sign_in -
    8. -
      - -
      -
    9. - - - - - - # def create -
    10. -
      - -
      -
    11. - - - - - - # super -
    12. -
      - -
      -
    13. - - - - - - # end -
    14. -
      - -
      -
    15. - +
    16. + 1 - + module BlocksHelper
    17. -
    18. +
    19. - # DELETE /resource/sign_out + end
    20. -
      -
    21. - - - - +
    +
    + - # def destroy - - -
    -
  • - - +
    +
    +

    app/helpers/chains_helper.rb

    +

    + + 100.0% + - + lines covered +

    - # super -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - # end -
  • -
    - -
    -
  • - - + - +
  • - - - +
    +    
      -
    1. +
    2. - # protected + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -9614,51 +9607,18 @@

    6. -
    7. - - - - - - # If you have extra params to permit, append them to the sanitizer. -
    8. -
      - -
      -
    9. - - - - - - # def configure_sign_in_params -
    10. -
      - -
      -
    11. - - - - - - # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute]) -
    12. -
      - -
      -
    13. - +
    14. + 1 - # end + module ChainsHelper
    15. -
    16. +
    17. @@ -9673,12 +9633,12 @@

    18. -
      +
      -

      app/controllers/users/unlocks_controller.rb

      +

      app/helpers/contracts_helper.rb

      - - 0.0% + + 100.0% lines covered @@ -9687,9 +9647,9 @@

      - 2 relevant lines. - 0 lines covered and - 2 lines missed. + 1 relevant lines. + 1 lines covered and + 0 lines missed.
      @@ -9722,13 +9682,13 @@

      -
    19. - +
    20. + 1 - class Users::UnlocksController < Devise::UnlocksController + module ContractsHelper
    21. @@ -9739,177 +9699,129 @@

      - # GET /resource/unlock/new - -

      - -
      -
    22. - - - - - - # def new -
    23. -
      - -
      -
    24. - - - - - - # super + end
    25. -
      -
    26. - - - - +
    +
    + - # end - - -
    -
  • - - +
    +
    +

    app/helpers/pools_helper.rb

    +

    + + 100.0% + - + lines covered +

    - -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - # POST /resource/unlock -
  • -
    - -
    -
  • - - + - +
  • - # def create - - +
    +    
      -
    1. +
    2. - # super + # frozen_string_literal: true
    3. -
    4. +
    5. - # end +
    6. -
    7. - +
    8. + 1 - + module PoolsHelper
    9. -
    10. +
    11. - # GET /resource/unlock?unlock_token=abcdef + end
    12. -
      -
    13. - - - - +
    +
    + - # def show - - -
    -
  • - - +
    +
    +

    app/helpers/signatures_helper.rb

    +

    + + 100.0% + - + lines covered +

    - # super -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - # end -
  • -
    - -
    -
  • - - + - +
  • - - - +
    +    
      -
    1. +
    2. - # protected + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -9920,106 +9832,93 @@

    6. -
    7. - +
    8. + 1 - # The path used after sending unlock password instructions + module SignaturesHelper
    9. -
    10. +
    11. - # def after_sending_unlock_instructions_path_for(resource) + end
    12. -
      -
    13. - - - - +
    +
    + - # super(resource) - - -
    -
  • - - +
    +
    +

    app/helpers/tickets_helper.rb

    +

    + + 100.0% + - + lines covered +

    - # end -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - -
  • -
    - -
    -
  • - - + - +
  • - # The path used after unlocking the resource - - +
    +    
      -
    1. +
    2. - # def after_unlock_path_for(resource) + # frozen_string_literal: true
    3. -
    4. +
    5. - # super(resource) +
    6. -
    7. - +
    8. + 1 - # end + module TicketsHelper
    9. -
    10. +
    11. @@ -10034,12 +9933,12 @@

    12. -
      +
      -

      app/controllers/wallets_controller.rb

      +

      app/helpers/transactions_helper.rb

      - - 0.0% + + 100.0% lines covered @@ -10048,9 +9947,9 @@

      - 13 relevant lines. - 0 lines covered and - 13 lines missed. + 1 relevant lines. + 1 lines covered and + 0 lines missed.
      @@ -10083,84 +9982,71 @@

      -
    13. - +
    14. + 1 - class WalletsController < ApplicationController + module TransactionsHelper
    15. -
    16. +
    17. - before_action :set_wallet, only: %i[ show edit update destroy ] + end
    18. -
      -
    19. - - - - +
    +
    + - before_action :authenticate_user! - - -
    -
  • - - +
    +
    +

    app/helpers/wallets_helper.rb

    +

    + + 100.0% + - + lines covered +

    - -
  • -
    - -
    -
  • - - + - +
    + 1 relevant lines. + 1 lines covered and + 0 lines missed. +
    - def index -
  • -
    - -
    -
  • - - + - +
  • - @wallets = current_user.wallet - - +
    +    
      -
    1. +
    2. - end + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -10171,84 +10057,115 @@

    6. -
    7. - +
    8. + 1 - def show + module WalletsHelper
    9. -
    10. +
    11. - end + end
    12. +
    +
    + + + +
    +
    +

    app/mailers/application_mailer.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 3 relevant lines. + 3 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - + # frozen_string_literal: true
    3. -
    4. +
    5. - private +
    6. -
    7. - +
    8. + 1 - def set_wallet + class ApplicationMailer < ActionMailer::Base
    9. -
    10. - +
    11. + 1 - @wallet = Wallet.find(params[:id]) + default from: "from@example.com"
    12. -
    13. - +
    14. + 1 - end + layout "mailer"
    15. -
    16. +
    17. @@ -10263,9 +10180,9 @@

    18. -
      +
      -

      app/helpers/application_helper.rb

      +

      app/models/acceptable_number_sequence.rb

      100.0% @@ -10318,7 +10235,7 @@

      - module ApplicationHelper + class AcceptableNumberSequence < ApplicationRecord

      @@ -10338,9 +10255,9 @@

      -
      +
      -

      app/helpers/blocks_helper.rb

      +

      app/models/acceptable_symbol_sequence.rb

      100.0% @@ -10393,7 +10310,7 @@

      - module BlocksHelper + class AcceptableSymbolSequence < ApplicationRecord

      @@ -10413,9 +10330,9 @@

      -
      +
      -

      app/helpers/chains_helper.rb

      +

      app/models/acceptable_word.rb

      100.0% @@ -10468,7 +10385,7 @@

      - module ChainsHelper + class AcceptableWord < ApplicationRecord

      @@ -10488,9 +10405,9 @@

      -
      +
      -

      app/helpers/contracts_helper.rb

      +

      app/models/application_record.rb

      100.0% @@ -10502,8 +10419,8 @@

      - 1 relevant lines. - 1 lines covered and + 2 relevant lines. + 2 lines covered and 0 lines missed.
      @@ -10543,12 +10460,23 @@

      - module ContractsHelper + class ApplicationRecord < ActiveRecord::Base

      -
    19. +
    20. + 1 + + + + + primary_abstract_class +
    21. +
      + +
      +
    22. @@ -10563,9 +10491,9 @@

    23. -
      +
      -

      app/helpers/pools_helper.rb

      +

      app/models/block.rb

      100.0% @@ -10577,8 +10505,8 @@

      - 1 relevant lines. - 1 lines covered and + 12 relevant lines. + 12 lines covered and 0 lines missed.
      @@ -10618,162 +10546,155 @@

      - module PoolsHelper + class Block < ApplicationRecord

      -
    24. - +
    25. + 1 - end + belongs_to :chain
    26. -
    -
    -
    +
    +
  • + 1 + + + + validates :nonce, presence: true +
  • +
    -
    -
    -

    app/helpers/signatures_helper.rb

    -

    - - 100.0% - +
    +
  • + 1 + - lines covered -
  • + - + validates :previous_hash, presence: true + +
    + +
    +
  • + 1 + -
    - 1 relevant lines. - 1 lines covered and - 0 lines missed. -
    + - + validates :block_data, presence: true +
  • +
    + +
    +
  • + 1 + -
  • + -
    -    
      + validates :connections, presence: true + +
    -
  • - +
  • + 1 - # frozen_string_literal: true + has_many :transactions, dependent: :destroy, counter_cache: true
  • -
  • - +
  • + 1 - + after_create :create_pool
  • -
  • +
  • 1 - module SignaturesHelper + has_one :pool, dependent: :destroy, inverse_of: :block
  • -
  • +
  • - end +
  • - - - - - -
    -
    -

    app/helpers/tickets_helper.rb

    -

    - - 100.0% - - - lines covered -

    - - - -
    - 1 relevant lines. - 1 lines covered and - 0 lines missed. -
    - - +
    +
  • + 1 + -
  • + -
    -    
      + private + +
    -
  • - +
  • + 1 - # frozen_string_literal: true + def create_pool
  • -
  • - +
  • + 68 - + Pool.create(block_id: self.id)
  • -
  • - 1 +
  • + - module TicketsHelper + end
  • -
  • +
  • @@ -10788,9 +10709,9 @@

  • -
    +
    -

    app/helpers/transactions_helper.rb

    +

    app/models/chain.rb

    100.0% @@ -10802,8 +10723,8 @@

    - 1 relevant lines. - 1 lines covered and + 6 relevant lines. + 6 lines covered and 0 lines missed.
    @@ -10843,65 +10764,56 @@

    - module TransactionsHelper + class Chain < ApplicationRecord

    -
  • - +
  • + 1 - end + validates :name, presence: true, uniqueness: true, length: { maximum: 20 }
  • - - -
    - - -
    -
    -

    app/helpers/wallets_helper.rb

    -

    - - 100.0% - - - lines covered -

    - - +
    +
  • + 1 + -
    - 1 relevant lines. - 1 lines covered and - 0 lines missed. -
    + - + validates :maintainer, presence: true, length: { maximum: 50 } +
  • +
    + +
    +
  • + 1 + -
  • + -
    -    
      + validates :chain_version, presence: true, length: { maximum: 20 } + +
    -
  • - +
  • + 1 - # frozen_string_literal: true + validates :description, presence: true, length: { maximum: 1000 }
  • -
  • +
  • @@ -10912,18 +10824,18 @@

  • -
  • +
  • 1 - module WalletsHelper + has_many :blocks, dependent: :destroy
  • -
  • +
  • @@ -10938,9 +10850,9 @@

  • -
    +
    -

    app/mailers/application_mailer.rb

    +

    app/models/concerns/sequences_validator.rb

    0.0% @@ -10952,9 +10864,9 @@

    - 4 relevant lines. + 23 relevant lines. 0 lines covered and - 4 lines missed. + 23 lines missed.
    @@ -10993,7 +10905,7 @@

    - class ApplicationMailer < ActionMailer::Base + class SequencesValidator < ActiveModel::Validator

    @@ -11004,7 +10916,7 @@

    - default from: "from@example.com" + def validate(record)

    @@ -11015,7 +10927,7 @@

    - layout "mailer" + @record = record

    @@ -11026,54 +10938,56 @@

    - end + @word = record.common_word

    - - -
    - - -
    -
    -

    app/models/acceptable_number_sequence.rb

    -

    - - 0.0% - +
    +
  • + + - lines covered -
  • + - + @symbol_seq = record.symbol_sequence + +
    + +
    +
  • + + -
    - 2 relevant lines. - 0 lines covered and - 2 lines missed. -
    + - + @number_seq = record.number_sequence +
  • +
    + +
    +
  • + + -
  • + -
    -    
      + record.errors.add(:base, "Invalid Hashable Content") unless valid_checker + +
    -
  • +
  • - # frozen_string_literal: true + end
  • -
  • +
  • @@ -11084,146 +10998,117 @@

  • -
  • +
  • - class AcceptableNumberSequence < ApplicationRecord + private
  • -
  • +
  • - end + attr_reader :record, :word, :symbol_seq, :number_seq
  • - - -
    - - -
    -
    -

    app/models/acceptable_symbol_sequence.rb

    -

    - - 0.0% - - - lines covered -

    - - +
    +
  • + + -
    - 2 relevant lines. - 0 lines covered and - 2 lines missed. -
    + - + +
  • +
    + +
    +
  • + + -
  • + -
    -    
      + def valid_checker + +
    -
  • +
  • - # frozen_string_literal: true + acceptable_word? && acceptable_symbol_sequence? && acceptable_number_sequence?
  • -
  • +
  • - + end
  • -
  • +
  • - class AcceptableSymbolSequence < ApplicationRecord +
  • -
  • +
  • - end + def acceptable_word?
  • - - -
    - - -
    -
    -

    app/models/acceptable_word.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 2 relevant lines. - 0 lines covered and - 2 lines missed. -
    - - +
    +
  • + + -
  • + -
    -    
      + AcceptableWord.find_by(word: word).present? + +
    -
  • +
  • - # frozen_string_literal: true + end
  • -
  • +
  • @@ -11234,104 +11119,84 @@

  • -
  • +
  • - class AcceptableWord < ApplicationRecord + def acceptable_symbol_sequence?
  • -
  • +
  • - end + AcceptableSymbolSequence.find_by(seq: symbol_seq).present?
  • - - -
    - - -
    -
    -

    app/models/application_record.rb

    -

    - - 100.0% - - - lines covered -

    - - - -
    - 2 relevant lines. - 2 lines covered and - 0 lines missed. -
    - - +
    +
  • + + -
  • + -
    -    
      + end + +
    -
  • +
  • - # frozen_string_literal: true +
  • -
  • +
  • - + def acceptable_number_sequence?
  • -
  • - 1 +
  • + - class ApplicationRecord < ActiveRecord::Base + AcceptableNumberSequence.find_by(seq: number_seq).present?
  • -
  • - 1 +
  • + - primary_abstract_class + end
  • -
  • +
  • @@ -11346,12 +11211,12 @@

  • -
    +
    -

    app/models/block.rb

    +

    app/models/concerns/wallet_exists_validator.rb

    - - 0.0% + + 100.0% lines covered @@ -11360,9 +11225,9 @@

    - 14 relevant lines. - 0 lines covered and - 14 lines missed. + 6 relevant lines. + 6 lines covered and + 0 lines missed.
    @@ -11395,106 +11260,62 @@

    -
  • - - - - - - class Block < ApplicationRecord -
  • -
    - -
    -
  • - - - - - - belongs_to :chain -
  • -
    - -
    -
  • - - - - - - validates :nonce, presence: true -
  • -
    - -
    -
  • - - - - - - validates :previous_hash, presence: true -
  • -
    - -
    -
  • - +
  • + 1 - validates :block_data, presence: true + class WalletExistsValidator < ActiveModel::Validator
  • -
  • - +
  • + 1 - validates :connections, presence: true + def validate(record)
  • -
  • - +
  • + 52 - has_many :transactions, dependent: :destroy, counter_cache: true + if Wallet.find_by(pr_key: record.receiver_key).nil?
  • -
  • - +
  • + 13 - after_create :create_pool + record.errors[:sender_key] << "Sender key is not valid"
  • -
  • +
  • - has_one :pool, dependent: :destroy, inverse_of: :block + end
  • -
  • +
  • @@ -11505,51 +11326,51 @@

  • -
  • - +
  • + 52 - private + if Wallet.find_by(pv_key: record.sender_key).nil?
  • -
  • - +
  • + 13 - def create_pool + record.errors[:receiver_key] << "Receiver key is not valid"
  • -
  • +
  • - Pool.create(block_id: self.id) + end
  • -
  • +
  • - end + end
  • -
  • +
  • @@ -11564,133 +11385,100 @@

  • -
    +
    -

    app/models/chain.rb

    +

    app/models/contract.rb

    - - 0.0% + + 100.0% lines covered

    - - -
    - 7 relevant lines. - 0 lines covered and - 7 lines missed. -
    - - - -
    - -
    -    
      - -
      -
    1. - - - - - - # frozen_string_literal: true -
    2. -
      - -
      -
    3. - - - - + - -
    4. -
      - -
      -
    5. - - +
      + 4 relevant lines. + 4 lines covered and + 0 lines missed. +
      - + - class Chain < ApplicationRecord -
    6. -
      +
    + +
    +    
      -
    1. +
    2. - validates :name, presence: true, uniqueness: true, length: { maximum: 20 } + # frozen_string_literal: true
    3. -
    4. +
    5. - validates :maintainer, presence: true, length: { maximum: 50 } +
    6. -
    7. - +
    8. + 1 - validates :chain_version, presence: true, length: { maximum: 20 } + class Contract < ApplicationRecord
    9. -
    10. - +
    11. + 1 - validates :description, presence: true, length: { maximum: 1000 } + validates :blk_transaction, presence: true
    12. -
    13. - +
    14. + 1 - + belongs_to :blk_transaction, class_name: "Transaction", foreign_key: "transaction_id", inverse_of: :contract
    15. -
    16. - +
    17. + 1 - has_many :blocks, dependent: :destroy + has_many :signatures, inverse_of: :contract, dependent: :destroy
    18. -
    19. +
    20. @@ -11705,12 +11493,12 @@

    21. -
      +
      -

      app/models/concerns/sequences_validator.rb

      +

      app/models/pool.rb

      - - 0.0% + + 100.0% lines covered @@ -11719,9 +11507,9 @@

      - 23 relevant lines. - 0 lines covered and - 23 lines missed. + 2 relevant lines. + 2 lines covered and + 0 lines missed.
      @@ -11754,304 +11542,344 @@

      -
    22. - +
    23. + 1 - class SequencesValidator < ActiveModel::Validator + class Pool < ApplicationRecord
    24. -
    25. - +
    26. + 1 - def validate(record) + belongs_to :block
    27. -
    28. +
    29. - @record = record + end
    30. -
      -
    31. - - +
    +
    +
    - + +
    +
    +

    app/models/signature.rb

    +

    + + 100.0% + - @word = record.common_word - -

    + lines covered +

    + + + +
    + 5 relevant lines. + 5 lines covered and + 0 lines missed. +
    + + + + + +
    +    
      -
    1. +
    2. - @symbol_seq = record.symbol_sequence + # frozen_string_literal: true
    3. -
    4. +
    5. - @number_seq = record.number_sequence +
    6. -
    7. - +
    8. + 1 - record.errors.add(:base, "Invalid Hashable Content") unless valid_checker + class Signature < ApplicationRecord
    9. -
    10. - +
    11. + 1 - end + belongs_to :contract
    12. -
    13. - +
    14. + 1 - + belongs_to :ticket
    15. -
    16. - +
    17. + 1 - private + belongs_to :user
    18. -
    19. - +
    20. + 1 - attr_reader :record, :word, :symbol_seq, :number_seq + validates :signature, presence: true, length: { is: 64 }, uniqueness: true
    21. -
    22. +
    23. - + # validates :common_word, presence: true
    24. -
    25. +
    26. - def valid_checker + # validates :symbol_sequence, presence: true
    27. -
    28. +
    29. - acceptable_word? && acceptable_symbol_sequence? && acceptable_number_sequence? + # validates :number_sequence, presence: true
    30. -
    31. +
    32. - end + # validates_with SequencesValidator
    33. -
    34. +
    35. - + end
    36. -
      -
    37. - - +
    +
    + - + +
    +
    +

    app/models/ticket.rb

    +

    + + 100.0% + - def acceptable_word? - -

    + lines covered +

    + + + +
    + 7 relevant lines. + 7 lines covered and + 0 lines missed. +
    + + + + + +
    +    
      -
    1. +
    2. - AcceptableWord.find_by(word: word).present? + # frozen_string_literal: true
    3. -
    4. +
    5. - end +
    6. -
    7. - +
    8. + 1 - + class Ticket < ApplicationRecord
    9. -
    10. - +
    11. + 1 - def acceptable_symbol_sequence? + belongs_to :user
    12. -
    13. - +
    14. + 1 - AcceptableSymbolSequence.find_by(seq: symbol_seq).present? + belongs_to :pool
    15. -
    16. - +
    17. + 1 - end + validates :time_ref, presence: true
    18. -
    19. - +
    20. + 1 - + validates :status, presence: true
    21. -
    22. - +
    23. + 1 - def acceptable_number_sequence? + has_many :signatures
    24. -
    25. +
    26. - AcceptableNumberSequence.find_by(seq: number_seq).present? +
    27. -
    28. - +
    29. + 1 - end + enum status: { active: 0, inactive: 1 }
    30. -
    31. +
    32. @@ -12066,12 +11894,12 @@

    33. -
      +
      -

      app/models/concerns/wallet_exists_validator.rb

      +

      app/models/transaction.rb

      - - 0.0% + + 100.0% lines covered @@ -12080,9 +11908,9 @@

      - 10 relevant lines. - 0 lines covered and - 10 lines missed. + 16 relevant lines. + 16 lines covered and + 0 lines missed.
      @@ -12115,225 +11943,249 @@

      -
    34. - +
    35. + 1 - class WalletExistsValidator < ActiveModel::Validator + class Transaction < ApplicationRecord
    36. -
    37. - +
    38. + 1 - def validate(record) + include ActiveModel::Validations
    39. -
    40. - +
    41. + 1 - if Wallet.find_by(pr_key: record.receiver_key).nil? + validates :sender_key, presence: true
    42. -
    43. - +
    44. + 1 - record.errors[:sender_key] << "Sender key is not valid" + validates :receiver_key, presence: true
    45. -
    46. - +
    47. + 1 - end + validates :fee, presence: true, numericality: { greater_than: 0 }
    48. -
    49. - +
    50. + 1 - + validates :amount, presence: true, numericality: { greater_than: 0 }
    51. -
    52. - +
    53. + 1 - if Wallet.find_by(pv_key: record.sender_key).nil? + validates_with WalletExistsValidator
    54. -
    55. - +
    56. + 1 - record.errors[:receiver_key] << "Receiver key is not valid" + belongs_to :block
    57. -
    58. - +
    59. + 1 - end + has_one :contract, dependent: :destroy, inverse_of: :blk_transaction
    60. -
    61. - +
    62. + 1 - end + after_create :create_contract
    63. -
    64. +
    65. - end +
    66. -
    -
    - - - -
    -
    -

    app/models/contract.rb

    -

    - - 0.0% - +
    +
  • + 1 + - lines covered -
  • + - + def sender + +
    + +
    +
  • + 2 + -
    - 5 relevant lines. - 0 lines covered and - 5 lines missed. -
    + - + Wallet.find_by(pv_key: sender_key).user.username +
  • +
    + +
    +
  • + + -
  • + -
    -    
      + end + +
    -
  • +
  • - # frozen_string_literal: true +
  • -
  • +
  • + 1 + + def receiver +
  • +
    + +
    +
  • + 2 - + + + Wallet.find_by(pr_key: receiver_key).user.username
  • -
  • +
  • - class Contract < ApplicationRecord + end
  • -
  • +
  • - validates :blk_transaction, presence: true +
  • -
  • +
  • + 1 + + + + def create_contract +
  • +
    + +
    +
  • + 42 - belongs_to :blk_transaction, class_name: "Transaction", foreign_key: "transaction_id", inverse_of: :contract + Contract.create(blk_transaction: self)
  • -
  • +
  • - has_many :signatures, inverse_of: :contract, dependent: :destroy + end
  • -
  • +
  • @@ -12348,12 +12200,12 @@

  • -
    +
    -

    app/models/pool.rb

    +

    app/models/user.rb

    - - 0.0% + + 100.0% lines covered @@ -12362,9 +12214,9 @@

    - 3 relevant lines. - 0 lines covered and - 3 lines missed. + 27 relevant lines. + 27 lines covered and + 0 lines missed.
    @@ -12397,245 +12249,227 @@

    -
  • - +
  • + 1 - class Pool < ApplicationRecord + class User < ApplicationRecord
  • -
  • +
  • - belongs_to :block + # Include default devise modules. Others available are:
  • -
  • +
  • - end + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  • - - -
    +
    +
  • + 1 + + + + after_create :create_wallet +
  • +
    -
    -
    -

    app/models/signature.rb

    -

    - - 0.0% - +
    +
  • + 1 + - lines covered -
  • + - + devise :database_authenticatable, :registerable, + +
    + +
    +
  • + + -
    - 6 relevant lines. - 0 lines covered and - 6 lines missed. -
    + - + :recoverable, :rememberable, :validatable +
  • +
    + +
    +
  • + + -
  • + -
    -    
      + + +
    -
  • - +
  • + 1 - # frozen_string_literal: true + has_one :wallet
  • -
  • - +
  • + 1 - + has_many :tickets
  • -
  • - +
  • + 1 - class Signature < ApplicationRecord + validates :email, presence: true, uniqueness: true
  • -
  • - +
  • + 1 - belongs_to :contract + validates :password, presence: true, length: { minimum: 6 }
  • -
  • - +
  • + 1 - belongs_to :ticket + validates :username, presence: true, uniqueness: true
  • -
  • - +
  • + 1 - belongs_to :user + before_create :save_acceptable_assets
  • -
  • - +
  • + 1 - validates :signature, presence: true, length: { is: 64 }, uniqueness: true + before_create :save_api_keys
  • -
  • - +
  • + 1 - # validates :common_word, presence: true + has_many :signatures
  • -
  • +
  • - # validates :symbol_sequence, presence: true +
  • -
  • - +
  • + 1 - # validates :number_sequence, presence: true + private
  • -
  • - +
  • + 1 - # validates_with SequencesValidator + def create_wallet
  • -
  • - +
  • + 71 - end + CreateWalletWorker.perform_async(self.id)
  • - - -
    - - -
    -
    -

    app/models/ticket.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 8 relevant lines. - 0 lines covered and - 8 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true + end
    3. -
    4. +
    5. @@ -12646,73 +12480,73 @@

    6. -
    7. - +
    8. + 1 - class Ticket < ApplicationRecord + def save_acceptable_assets
    9. -
    10. - +
    11. + 71 - belongs_to :user + words = AcceptableWord.all.sample(4)
    12. -
    13. - +
    14. + 71 - belongs_to :pool + number_sequences = AcceptableNumberSequence.all.sample(4)
    15. -
    16. - +
    17. + 71 - validates :time_ref, presence: true + symbol_sequences = AcceptableSymbolSequence.all.sample(4)
    18. -
    19. +
    20. - validates :status, presence: true +
    21. -
    22. - +
    23. + 71 - has_many :signatures + words_to_save = words.map { |word| word.word }
    24. -
    25. +
    26. @@ -12723,71 +12557,40 @@

    27. -
    28. - +
    29. + 71 - enum status: { active: 0, inactive: 1 } + number_sequences_to_save = number_sequences.map { |number_sequence| number_sequence.seq }
    30. -
    31. +
    32. - end +
    33. -
    -
    -
    - - -
    -
    -

    app/models/transaction.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 20 relevant lines. - 0 lines covered and - 20 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. - +
    2. + 71 - # frozen_string_literal: true + symbol_sequences_to_save = symbol_sequences.map { |symbol_sequence| symbol_sequence.seq }
    3. -
    4. +
    5. @@ -12798,302 +12601,291 @@

    6. -
    7. - +
    8. + 71 - class Transaction < ApplicationRecord + self.acceptable_words = words_to_save
    9. -
    10. - +
    11. + 71 - include ActiveModel::Validations + self.acceptable_number_sequences = number_sequences_to_save
    12. -
    13. - +
    14. + 71 - validates :sender_key, presence: true + self.acceptable_symbol_sequences = symbol_sequences_to_save
    15. -
    16. +
    17. - validates :receiver_key, presence: true + end
    18. -
    19. +
    20. - validates :fee, presence: true, numericality: { greater_than: 0 } +
    21. -
    22. - +
    23. + 1 - validates :amount, presence: true, numericality: { greater_than: 0 } + def save_api_keys
    24. -
    25. - +
    26. + 71 - validates_with WalletExistsValidator + self.api_key = SecureRandom.hex(32)
    27. -
    28. - +
    29. + 71 - belongs_to :block + self.api_secret = SecureRandom.hex(32)
    30. -
    31. +
    32. - has_one :contract, dependent: :destroy, inverse_of: :blk_transaction + end
    33. -
    34. +
    35. - after_create :create_contract + end
    36. -
      -
    37. - - +
    +
    +
    - + +
    +
    +

    app/models/wallet.rb

    +

    + + 100.0% + - - -

    + lines covered +

    + + + +
    + 18 relevant lines. + 18 lines covered and + 0 lines missed. +
    + + + + + +
    +    
      -
    1. +
    2. - def sender + # frozen_string_literal: true
    3. -
    4. +
    5. - Wallet.find_by(pv_key: sender_key).user.username +
    6. -
      -
    7. - +
      +
    8. + 1 - end + class Wallet < ApplicationRecord
    9. -
    10. - +
    11. + 1 - + belongs_to :user
    12. -
    13. +
    14. - def receiver +
    15. -
    16. - +
    17. + 1 - Wallet.find_by(pr_key: receiver_key).user.username + validates :user_id, presence: true
    18. -
    19. - +
    20. + 1 - end + validates :pr_key, presence: false
    21. -
    22. - +
    23. + 1 - + validates :pv_key, presence: false
    24. -
    25. +
    26. - def create_contract + # validates :balance, presence: true, numericality: { equal_to: 0.0 }, on: :create
    27. -
    28. - +
    29. + 1 - Contract.create(blk_transaction: self) + validates :status, presence: true, inclusion: %w(active inactive)
    30. -
    31. +
    32. - end +
    33. -
    34. - +
    35. + 1 - end + before_create :create_keys
    36. -
    -
    - - - -
    -
    -

    app/models/user.rb

    -

    - - 55.56% - - - lines covered -

    - - - -
    - 27 relevant lines. - 15 lines covered and - 12 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true +
    3. -
    4. +
    5. @@ -13104,227 +12896,258 @@

    6. -
    7. +
    8. 1 - class User < ApplicationRecord + enum status: { active: 0, inactive: 1 }
    9. -
    10. +
    11. - # Include default devise modules. Others available are: +
    12. -
    13. - +
    14. + 1 - # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + def create_keys(pv_random = nil, pr_random = nil)
    15. -
    16. - 1 +
    17. + 59 - after_create :create_wallet + if pv_random.nil? && pr_random.nil?
    18. -
    19. - 1 +
    20. + 57 - devise :database_authenticatable, :registerable, + pv_random = SecureRandom.hex(64)
    21. -
    22. - +
    23. + 57 - :recoverable, :rememberable, :validatable + pr_random = SecureRandom.hex(64)
    24. -
    25. +
    26. - + end
    27. -
    28. - 1 +
    29. + - has_one :wallet +
    30. -
    31. - 1 +
    32. + 59 - has_many :tickets + dig_pv = Digest::SHA256.hexdigest(pv_random)
    33. -
    34. - 1 +
    35. + 59 - validates :email, presence: true, uniqueness: true + dig_pr = Digest::SHA256.hexdigest(pr_random)
    36. -
    37. - 1 +
    38. + - validates :password, presence: true, length: { minimum: 6 } +
    39. -
    40. - 1 +
    41. + 59 - validates :username, presence: true, uniqueness: true + if Wallet.exists?(pr_key: dig_pr) || Wallet.exists?(pv_key: dig_pv)
    42. -
    43. +
    44. 1 - before_create :save_acceptable_assets + raise "Key already exists"
    45. -
    46. - 1 +
    47. + - before_create :save_api_keys + else
    48. -
    49. - 1 +
    50. + 58 - has_many :signatures + self.pr_key = dig_pr
    51. -
    52. - +
    53. + 58 - + self.pv_key = dig_pv
    54. -
    55. - 1 +
    56. + - private + end
    57. -
    58. - 1 +
    59. + - def create_wallet + end
    60. -
    61. +
    62. - CreateWalletWorker.perform_async(self.id) + end
    63. +
    +
    +
    + + +
    +
    +

    app/services/application_service.rb

    +

    + + 91.67% + + + lines covered +

    + + + +
    + 12 relevant lines. + 11 lines covered and + 1 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - end + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -13335,95 +13158,95 @@

    6. -
    7. +
    8. 1 - def save_acceptable_assets + class ApplicationService
    9. -
    10. - +
    11. + 1 - words = AcceptableWord.all.sample(4) + private
    12. -
    13. - +
    14. + 1 - number_sequences = AcceptableNumberSequence.all.sample(4) + def dev_error(e)
    15. -
    16. - +
    17. + 1 - symbol_sequences = AcceptableSymbolSequence.all.sample(4) + if env_acceptable?
    18. -
    19. - +
    20. + 1 - + puts "#{e.class}: #{e.message}"
    21. -
    22. - +
    23. + 1 - words_to_save = words.map { |word| word.word } + puts e.backtrace
    24. -
    25. +
    26. - + end
    27. -
    28. +
    29. - number_sequences_to_save = number_sequences.map { |number_sequence| number_sequence.seq } + end
    30. -
    31. +
    32. @@ -13434,117 +13257,117 @@

    33. -
    34. - +
    35. + 1 - symbol_sequences_to_save = symbol_sequences.map { |symbol_sequence| symbol_sequence.seq } + def user_exists?
    36. -
    37. +
    38. - + User.find_by(id: user_id).present?
    39. -
    40. +
    41. - self.acceptable_words = words_to_save + end
    42. -
    43. +
    44. - self.acceptable_number_sequences = number_sequences_to_save +
    45. -
    46. - +
    47. + 1 - self.acceptable_symbol_sequences = symbol_sequences_to_save + def wallet_exists?(method, key)
    48. -
    49. - +
    50. + 12 - end + Wallet.find_by(method => key).present?
    51. -
    52. +
    53. - + end
    54. -
    55. - 1 +
    56. + - def save_api_keys +
    57. -
    58. - +
    59. + 1 - self.api_key = SecureRandom.hex(32) + def env_acceptable?
    60. -
    61. - +
    62. + 1 - self.api_secret = SecureRandom.hex(32) + Rails.env.development? || Rails.env.test?
    63. -
    64. +
    65. @@ -13555,7 +13378,7 @@

    66. -
    67. +
    68. @@ -13570,12 +13393,12 @@

    69. -
      +
      -

      app/models/wallet.rb

      +

      app/services/assign_contracts_service.rb

      - - 0.0% + + 100.0% lines covered @@ -13584,9 +13407,9 @@

      - 23 relevant lines. - 0 lines covered and - 23 lines missed. + 98 relevant lines. + 98 lines covered and + 0 lines missed.
      @@ -13619,90 +13442,90 @@

      -
    70. - +
    71. + 1 - class Wallet < ApplicationRecord + class AssignContractsService < ApplicationService
    72. -
    73. - +
    74. + 1 - belongs_to :user + def initialize(contract_ids, ticket_id)
    75. -
    76. - +
    77. + 11 - + @contract_ids = contract_ids
    78. -
    79. - +
    80. + 11 - validates :user_id, presence: true + @ticket_id = ticket_id
    81. -
    82. +
    83. - validates :pr_key, presence: false + end
    84. -
    85. +
    86. - validates :pv_key, presence: false +
    87. -
    88. - +
    89. + 1 - # validates :balance, presence: true, numericality: { equal_to: 0.0 }, on: :create + def call
    90. -
    91. - +
    92. + 11 - validates :status, presence: true, inclusion: %w(active inactive) + assign_contract
    93. @@ -13713,23 +13536,12 @@

      - - -

      - -
      -
    94. - - - - - - before_create :create_keys + end
    95. -
    96. +
    97. @@ -13740,29 +13552,29 @@

    98. -
    99. - +
    100. + 1 - + private
    101. -
    102. - +
    103. + 1 - enum status: { active: 0, inactive: 1 } + attr_reader :contract_ids, :ticket_id
    104. -
    105. +
    106. @@ -13773,51 +13585,29 @@

    107. -
    108. - - - - - - def create_keys(pv_random = nil, pr_random = nil) -
    109. -
      - -
      -
    110. - - - - - - if pv_random.nil? && pr_random.nil? -
    111. -
      - -
      -
    112. - +
    113. + 1 - pv_random = SecureRandom.hex(64) + def ticket
    114. -
    115. - +
    116. + 236 - pr_random = SecureRandom.hex(64) + @ticket ||= Ticket.find_by(id: ticket_id)
    117. -
    118. +
    119. @@ -13828,7 +13618,7 @@

    120. -
    121. +
    122. @@ -13839,95 +13629,73 @@

    123. -
    124. - - - - - - dig_pv = Digest::SHA256.hexdigest(pv_random) -
    125. -
      - -
      -
    126. - - - - - - dig_pr = Digest::SHA256.hexdigest(pr_random) -
    127. -
      - -
      -
    128. - +
    129. + 1 - + def contracts
    130. -
    131. - +
    132. + 22 - if Wallet.exists?(pr_key: dig_pr) || Wallet.exists?(pv_key: dig_pv) + @contracts ||= Contract.where(id: contract_ids)
    133. -
    134. +
    135. - raise "Key already exists" + end
    136. -
    137. +
    138. - else +
    139. -
    140. - +
    141. + 1 - self.pr_key = dig_pr + def block
    142. -
    143. - +
    144. + 184 - self.pv_key = dig_pv + @block ||= Block.where(master_hash: nil).last
    145. -
    146. +
    147. @@ -13938,159 +13706,128 @@

    148. -
    149. +
    150. - end +
    151. -
    152. - +
    153. + 1 - end + def block_confirmed?
    154. -
    -
    -
    - - -
    -
    -

    app/services/application_service.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 18 relevant lines. - 0 lines covered and - 18 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. - +
    2. + 150 - # frozen_string_literal: true + block.nonce >= ENV["CONTRACTS_LIMIT"].to_i
    3. -
    4. +
    5. - + end
    6. -
    7. +
    8. - class ApplicationService +
    9. -
    10. - +
    11. + 1 - private + def update_nonce
    12. -
    13. - +
    14. + 10 - def dev_error(e) + block.update(nonce: block.nonce + 1)
    15. -
    16. +
    17. - if env_acceptable? + end
    18. -
    19. +
    20. - puts "#{e.class}: #{e.message}" +
    21. -
    22. - +
    23. + 1 - puts e.backtrace + def signatures_limit_reached?(contract)
    24. -
    25. - +
    26. + 300 - end + contract.signatures.count == ENV["SIGNATURES_LIMIT"].to_i
    27. -
    28. +
    29. @@ -14101,7 +13838,7 @@

    30. -
    31. +
    32. @@ -14112,247 +13849,216 @@

    33. -
    34. - +
    35. + 1 - def user_exists? + def create_block
    36. -
    37. - +
    38. + 2 - User.find_by(id: user_id).present? + Block.create!(chain: Chain.first, previous_hash: block.master_hash,
    39. -
    40. +
    41. - end + master_hash: nil, nonce: 0, connections: 0, contracts_count: 0,
    42. -
    43. +
    44. - + contracts_limit: ENV["CONTRACTS_LIMIT"].to_i, block_data: "block #{block.id + 1}")
    45. -
    46. +
    47. - def wallet_exists?(method, key) + end
    48. -
    49. +
    50. - Wallet.find_by(method => key).present? +
    51. -
    52. - +
    53. + 1 - end + def confirm_block
    54. -
    55. - +
    56. + 12 - + return if confirmed_now == true
    57. -
    58. - +
    59. + 2 - def env_acceptable? + @confirmed_now = true
    60. -
    61. - +
    62. + 2 - Rails.env.development? || Rails.env.test? + block.update(master_hash: generate_master_hash)
    63. -
    64. - +
    65. + 2 - end + block.reload
    66. -
    67. - +
    68. + 2 - end + @new_block = create_block
    69. -
    -
    -
    - - -
    -
    -

    app/services/assign_contracts_service.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 134 relevant lines. - 0 lines covered and - 134 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. - +
    2. + 2 - # frozen_string_literal: true + pay_receivers
    3. -
    4. - +
    5. + 2 - + pay_miners
    6. -
    7. +
    8. - class AssignContractsService < ApplicationService + end
    9. -
    10. +
    11. - def initialize(contract_ids, ticket_id) +
    12. -
    13. - +
    14. + 1 - @contract_ids = contract_ids + def complete_contracts
    15. -
    16. - +
    17. + 77 - @ticket_id = ticket_id + @complete_contracts ||= []
    18. -
    19. +
    20. - end + end
    21. -
    22. +
    23. @@ -14363,40 +14069,40 @@

    24. -
    25. - +
    26. + 1 - def call + def uncomplete_contracts
    27. -
    28. - +
    29. + 75 - assign_contract + @uncomplete_contracts ||= []
    30. -
    31. +
    32. - end + end
    33. -
    34. +
    35. @@ -14407,29 +14113,40 @@

    36. -
    37. +
    38. + 1 + + def signatures +
    39. +
      + +
      +
    40. + 86 - private + + + @signatures ||= []
    41. -
    42. +
    43. - attr_reader :contract_ids, :ticket_id + end
    44. -
    45. +
    46. @@ -14440,29 +14157,29 @@

    47. -
    48. - +
    49. + 1 - def ticket + def generate_master_hash
    50. -
    51. - +
    52. + 2 - @ticket ||= Ticket.find_by(id: ticket_id) + Digest::SHA256.hexdigest(complete_contracts.map(&:signatures).flatten.map(&:signature).join)
    53. -
    54. +
    55. @@ -14473,7 +14190,7 @@

    56. -
    57. +
    58. @@ -14484,29 +14201,29 @@

    59. -
    60. - +
    61. + 1 - def contracts + def complete_contracts_limit_reached?
    62. -
    63. - +
    64. + 75 - @contracts ||= Contract.where(id: contract_ids) + complete_contracts.count == ENV["CONTRACTS_LIMIT"].to_i
    65. -
    66. +
    67. @@ -14517,7 +14234,7 @@

    68. -
    69. +
    70. @@ -14528,29 +14245,29 @@

    71. -
    72. - +
    73. + 1 - def block + def confirmed_now
    74. -
    75. - +
    76. + 87 - @block ||= Block.where(master_hash: nil).last + @confirmed_now ||= false
    77. -
    78. +
    79. @@ -14561,7 +14278,7 @@

    80. -
    81. +
    82. @@ -14572,183 +14289,194 @@

    83. -
    84. - +
    85. + 1 - def block_confirmed? + def pay_receivers
    86. -
    87. - +
    88. + 2 - block.nonce >= ENV["CONTRACTS_LIMIT"].to_i + block_transactions = block.transactions
    89. -
    90. - +
    91. + 2 - end + conts = block_transactions.map(&:contract)
    92. -
    93. - +
    94. + 2 - + conts_to_destroy = []
    95. -
    96. - +
    97. + 2 - def update_nonce + conts.each do |contract|
    98. -
    99. - +
    100. + 20 - block.update(nonce: block.nonce + 1) + if contract.signatures.count < ENV["SIGNATURES_LIMIT"].to_i
    101. -
    102. - +
    103. + 10 - end + transact = block_transactions.find_by(contract: contract)
    104. -
    105. - +
    106. + 10 - + conts_to_destroy << contract.id
    107. -
    108. +
    109. + 10 + + + + transact.update(block: @new_block) +
    110. +
      + +
      +
    111. + 10 - def signatures_limit_reached?(contract) + Contract.create(blk_transaction: transact)
    112. -
    113. +
    114. - contract.signatures.count == ENV["SIGNATURES_LIMIT"].to_i + end
    115. -
    116. - +
    117. + 20 - end + amount = contract.blk_transaction.amount.to_f - contract.blk_transaction.fee.to_f
    118. -
    119. - +
    120. + 20 - + wallet = Wallet.find_by(pr_key: contract.blk_transaction.receiver_key)
    121. -
    122. - +
    123. + 20 - def create_block + wallet.update(balance: wallet.balance + amount)
    124. -
    125. +
    126. - Block.create!(chain: Chain.first, previous_hash: block.master_hash, + end
    127. -
    128. +
    129. - master_hash: nil, nonce: 0, connections: 0, contracts_count: 0, +
    130. -
    131. - +
    132. + 2 - contracts_limit: ENV["CONTRACTS_LIMIT"].to_i, block_data: "block #{block.id + 1}") + Contract.where(id: conts_to_destroy).destroy_all
    133. -
    134. +
    135. @@ -14759,7 +14487,7 @@

    136. -
    137. +
    138. @@ -14770,282 +14498,282 @@

    139. -
    140. - +
    141. + 1 - def confirm_block + def payed_miners
    142. -
    143. - +
    144. + 4 - return if confirmed_now == true + @payed_miners ||= []
    145. -
    146. +
    147. - @confirmed_now = true + end
    148. -
    149. +
    150. - block.update(master_hash: generate_master_hash) +
    151. -
    152. - +
    153. + 1 - block.reload + def pay_miners
    154. -
    155. - +
    156. + 2 - @new_block = create_block + tickets = Ticket.where(pool_id: block.pool.id)
    157. -
    158. - +
    159. + 2 - pay_receivers + total_signatures = tickets.map(&:signatures).map(&:count).sum
    160. -
    161. - +
    162. + 2 - pay_miners + counted_users = []
    163. -
    164. - +
    165. + 2 - end + amount_to_pay = []
    166. -
    167. - +
    168. + 2 - + tickets.each do |ticket|
    169. -
    170. - +
    171. + 10 - def complete_contracts + signatures = ticket.signatures
    172. -
    173. - +
    174. + 10 - @complete_contracts ||= [] + user = ticket.user
    175. -
    176. - +
    177. + 10 - end + unless counted_users.include?(user)
    178. -
    179. - +
    180. + 2 - + counted_users << user
    181. -
    182. - +
    183. + 2 - def uncomplete_contracts + amount_to_pay << signatures.count
    184. -
    185. +
    186. - @uncomplete_contracts ||= [] + else
    187. -
    188. - +
    189. + 8 - end + amount_to_pay[counted_users.index(user)] += signatures.count
    190. -
    191. +
    192. - + end
    193. -
    194. +
    195. - def signatures + end
    196. -
    197. - +
    198. + 2 - @signatures ||= [] + amount_to_pay.each_with_index do |amount, index|
    199. -
    200. - +
    201. + 2 - end + next if payed_miners.include?(counted_users[index])
    202. -
    203. - +
    204. + 2 - + wallet = counted_users[index].wallet
    205. -
    206. - +
    207. + 2 - # block master hash is all unique contracts signatures hashed in SHA256 + wallet.update(balance: wallet.balance + (amount.to_f / total_signatures.to_f) * block.pool.amount)
    208. -
    209. - +
    210. + 2 - def generate_master_hash + payed_miners << counted_users[index]
    211. -
    212. +
    213. - Digest::SHA256.hexdigest(complete_contracts.map(&:signatures).flatten.map(&:signature).join) + end
    214. -
    215. +
    216. @@ -15056,7 +14784,7 @@

    217. -
    218. +
    219. @@ -15067,29 +14795,40 @@

    220. -
    221. - +
    222. + 1 - def complete_contracts_limit_reached? + def new_signature(contract)
    223. -
    224. +
    225. + 75 + + + + contract.update(signatures_count: contract.signatures_count + 1) +
    226. +
      + +
      +
    227. + 75 - complete_contracts.count == ENV["CONTRACTS_LIMIT"].to_i + Signature.new(contract_id: contract.id, signature: ticket.user_acceptable_hash, ticket_id: ticket.id, user_id: ticket.user_id)
    228. -
    229. +
    230. @@ -15100,7 +14839,7 @@

    231. -
    232. +
    233. @@ -15111,29 +14850,40 @@

    234. -
    235. - +
    236. + 1 - def confirmed_now + def parse_in_arrays(contract)
    237. -
    238. +
    239. + 75 + + uncomplete_contracts << contract unless signatures_limit_reached?(contract) +
    240. +
      + +
      +
    241. + 75 - @confirmed_now ||= false + + + complete_contracts << contract if signatures_limit_reached?(contract)
    242. -
    243. +
    244. @@ -15144,7 +14894,7 @@

    245. -
    246. +
    247. @@ -15155,172 +14905,172 @@

    248. -
    249. - +
    250. + 1 - def pay_receivers + def add_signature(contract)
    251. -
    252. - +
    253. + 75 - block_transactions = block.transactions + return if signatures_limit_reached?(contract) || confirmed_now == true || block_confirmed?
    254. -
    255. - +
    256. + 75 - conts = block_transactions.map(&:contract) + signatures << new_signature(contract)
    257. -
    258. - +
    259. + 75 - conts_to_destroy = [] + contract.update(status: (contract.status + 1))
    260. -
    261. +
    262. - conts.each do |contract| + end
    263. -
    264. +
    265. - if contract.signatures.count < ENV["SIGNATURES_LIMIT"].to_i +
    266. -
    267. - +
    268. + 1 - transact = block_transactions.find_by(contract: contract) + def block_actions(contract)
    269. -
    270. - +
    271. + 75 - conts_to_destroy << contract.id + update_nonce if signatures_limit_reached?(contract)
    272. -
    273. - +
    274. + 75 - transact.update(block: @new_block) + confirm_block if complete_contracts_limit_reached? || block_confirmed?
    275. -
    276. +
    277. - Contract.create(blk_transaction: transact) + end
    278. -
    279. +
    280. - end +
    281. -
    282. - +
    283. + 1 - amount = contract.blk_transaction.amount.to_f - contract.blk_transaction.fee.to_f + def signatures_import(signatures)
    284. -
    285. - +
    286. + 11 - wallet = Wallet.find_by(pr_key: contract.blk_transaction.receiver_key) + Signature.import signatures if signatures.present?
    287. -
    288. - +
    289. + 11 - wallet.update(balance: wallet.balance + amount) + ticket.update(status: :inactive)
    290. -
    291. +
    292. - end + end
    293. -
    294. +
    295. @@ -15331,315 +15081,346 @@

    296. -
    297. - +
    298. + 1 - Contract.where(id: conts_to_destroy).destroy_all + def assign_contract
    299. -
    300. - +
    301. + 11 - end + contracts.each do |contract|
    302. -
    303. - +
    304. + 75 - + parse_in_arrays(contract)
    305. -
    306. - +
    307. + 75 - def payed_miners + add_signature(contract)
    308. -
    309. +
    310. - @payed_miners ||= [] + end
    311. -
    312. - +
    313. + 11 - end + signatures_import(signatures)
    314. -
    315. - +
    316. + 11 - + contracts.each do |contract|
    317. -
    318. - +
    319. + 75 - def pay_miners + block_actions(contract)
    320. -
    321. +
    322. - tickets = Ticket.where(pool_id: block.pool.id) + end
    323. -
    324. +
    325. - total_signatures = tickets.map(&:signatures).map(&:count).sum + end
    326. -
    327. +
    328. - + + + end +
    329. +
      + +
    +
    +
    + + +
    +
    +

    app/services/create_ticket_service.rb

    +

    + + 0.0% + + + lines covered +

    + + + +
    + 71 relevant lines. + 0 lines covered and + 71 lines missed. +
    + + - counted_users = [] - -
    +
    + +
    +    
      -
    1. +
    2. - amount_to_pay = [] + # frozen_string_literal: true
    3. -
    4. +
    5. - tickets.each do |ticket| +
    6. -
    7. +
    8. - signatures = ticket.signatures + class CreateTicketService < ApplicationService
    9. -
    10. +
    11. - user = ticket.user + def initialize(user_id, pool_id, time_ref)
    12. -
    13. +
    14. - unless counted_users.include?(user) + @user_id = user_id
    15. -
    16. +
    17. - counted_users << user + @pool_id = pool_id
    18. -
    19. +
    20. - amount_to_pay << signatures.count + @time_ref = time_ref
    21. -
    22. +
    23. - else + end
    24. -
    25. +
    26. - amount_to_pay[counted_users.index(user)] += signatures.count +
    27. -
    28. +
    29. - end + def call
    30. -
    31. +
    32. - end + return false if ticket_exists?
    33. -
    34. +
    35. - amount_to_pay.each_with_index do |amount, index| + return false unless user_exists?
    36. -
    37. +
    38. - next if payed_miners.include?(counted_users[index]) + if ticket_created?
    39. -
    40. +
    41. - wallet = counted_users[index].wallet + update_block_connections
    42. -
    43. +
    44. - wallet.update(balance: wallet.balance + (amount.to_f / total_signatures.to_f) * block.pool.amount) + true
    45. -
    46. +
    47. - payed_miners << counted_users[index] + else
    48. -
    49. +
    50. - end + false
    51. -
    52. +
    53. @@ -15650,172 +15431,172 @@

    54. -
    55. +
    56. - + end
    57. -
    58. +
    59. - def new_signature(contract) +
    60. -
    61. +
    62. - contract.update(signatures_count: contract.signatures_count + 1) + private
    63. -
    64. +
    65. - Signature.new(contract_id: contract.id, signature: ticket.user_acceptable_hash, ticket_id: ticket.id, user_id: ticket.user_id) + attr_reader :user_id, :pool_id, :time_ref
    66. -
    67. +
    68. - end +
    69. -
    70. +
    71. - + def block
    72. -
    73. +
    74. - def parse_in_arrays(contract) + @block ||= Block.where(master_hash: nil).last
    75. -
    76. +
    77. - uncomplete_contracts << contract unless signatures_limit_reached?(contract) + end
    78. -
    79. +
    80. - complete_contracts << contract if signatures_limit_reached?(contract) +
    81. -
    82. +
    83. - end + def transactions
    84. -
    85. +
    86. - + @transactions ||= block.transactions.where(created_at: time_ref..Time.now)
    87. -
    88. +
    89. - def add_signature(contract) + end
    90. -
    91. +
    92. - return if signatures_limit_reached?(contract) || confirmed_now == true || block_confirmed? +
    93. -
    94. +
    95. - signatures << new_signature(contract) + def user
    96. -
    97. +
    98. - contract.update(status: (contract.status + 1)) + @user ||= User.find(user_id)
    99. -
    100. +
    101. @@ -15826,7 +15607,7 @@

    102. -
    103. +
    104. @@ -15837,40 +15618,29 @@

    105. -
    106. - - - - - - def block_actions(contract) -
    107. -
      - -
      -
    108. +
    109. - update_nonce if signatures_limit_reached?(contract) + def word
    110. -
    111. +
    112. - confirm_block if complete_contracts_limit_reached? || block_confirmed? + @word ||= user.acceptable_words.sample
    113. -
    114. +
    115. @@ -15881,7 +15651,7 @@

    116. -
    117. +
    118. @@ -15892,40 +15662,29 @@

    119. -
    120. - - - - - - def signatures_import(signatures) -
    121. -
      - -
      -
    122. +
    123. - Signature.import signatures if signatures.present? + def number_sequence
    124. -
    125. +
    126. - ticket.update(status: :inactive) + @number_sequence ||= user.acceptable_number_sequences.sample
    127. -
    128. +
    129. @@ -15936,7 +15695,7 @@

    130. -
    131. +
    132. @@ -15947,368 +15706,337 @@

    133. -
    134. +
    135. - def assign_contract + def symbol_sequence
    136. -
    137. +
    138. - contracts.each do |contract| + @symbol_sequence ||= user.acceptable_symbol_sequences.sample
    139. -
    140. +
    141. - parse_in_arrays(contract) + end
    142. -
    143. +
    144. - add_signature(contract) +
    145. -
    146. +
    147. - end + def generate_transaction_id_list
    148. -
    149. +
    150. - signatures_import(signatures) + transactions.map(&:id)
    151. -
    152. +
    153. - contracts.each do |contract| + end
    154. -
    155. +
    156. - block_actions(contract) +
    157. -
    158. +
    159. - end + def shuffled_string
    160. -
    161. +
    162. - end + puts "Word: #{word}"
    163. -
    164. +
    165. - end + puts "Number sequence: #{number_sequence}"
    166. -
    -
    - - - -
    -
    -

    app/services/create_ticket_service.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 67 relevant lines. - 0 lines covered and - 67 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true + puts "Symbol sequence: #{symbol_sequence}"
    3. -
    4. +
    5. - + string_sum = (word + number_sequence + symbol_sequence).split("").shuffle.join
    6. -
    7. +
    8. - class CreateTicketService < ApplicationService + puts "Shuffled string: #{string_sum}"
    9. -
    10. +
    11. - def initialize(user_id, pool_id, time_ref) + string_sum
    12. -
    13. +
    14. - @user_id = user_id + end
    15. -
    16. +
    17. - @pool_id = pool_id +
    18. -
    19. +
    20. - @time_ref = time_ref + def generate_user_acceptable_hash
    21. -
    22. +
    23. - end + hash = Digest::SHA256.hexdigest(shuffled_string)
    24. -
    25. +
    26. - + puts "Hash: #{hash}"
    27. -
    28. +
    29. - def call + block_hash = Digest::SHA256.hexdigest(@transactions.to_json)
    30. -
    31. +
    32. - return false if ticket_exists? + puts "Block hash: #{block_hash}"
    33. -
    34. +
    35. - return false unless user_exists? + master_hash = Digest::SHA256.hexdigest(hash + block_hash)
    36. -
    37. +
    38. - if ticket_created? + puts "Master hash: #{master_hash}"
    39. -
    40. +
    41. - update_block_connections + [hash, block_hash, master_hash]
    42. -
    43. +
    44. - true + end
    45. -
    46. +
    47. - else +
    48. -
    49. +
    50. - false + def update_block_connections
    51. -
    52. +
    53. - end + block.update(connections: (block.connections + 1))
    54. -
    55. +
    56. - end + end
    57. -
    58. +
    59. @@ -16319,161 +16047,192 @@

    60. -
    61. +
    62. - private + def ticket_created?
    63. -
    64. +
    65. - attr_reader :user_id, :pool_id, :time_ref + hash, block_hash, master_hash = generate_user_acceptable_hash
    66. -
    67. +
    68. - + @ticket = Ticket.new(user_id: user_id, status: :active, pool_id: pool_id,
    69. -
    70. +
    71. - def block + time_ref: time_ref, user_acceptable_hash: hash,
    72. -
    73. +
    74. - @block ||= Block.where(master_hash: nil).last + confirmation_hash: master_hash, block_hash: block_hash,
    75. -
    76. +
    77. - end + transaction_id_list: generate_transaction_id_list)
    78. -
    79. +
    80. - + @ticket.save ? true : false
    81. -
    82. +
    83. - def transactions + end
    84. -
    85. +
    86. - @transactions ||= block.transactions.where(created_at: time_ref..Time.now) +
    87. -
    88. +
    89. - end + def ticket_exists?
    90. -
    91. +
    92. - + Ticket.find_by(user_id: user_id, pool_id: pool_id, status: :active).present?
    93. -
    94. +
    95. - def user + end
    96. -
    97. +
    98. - @user ||= User.find(user_id) + end
    99. +
    +
    +
    + + +
    +
    +

    app/services/create_wallet_service.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 10 relevant lines. + 10 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - end + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -16484,381 +16243,412 @@

    6. -
    7. - +
    8. + 1 - def word + class CreateWalletService < ApplicationService
    9. -
    10. - +
    11. + 1 - @word ||= user.acceptable_words.sample + def initialize(user_id)
    12. -
    13. - +
    14. + 2 - end + @user_id = user_id
    15. -
    16. +
    17. - + end
    18. -
    19. +
    20. - def number_sequence +
    21. -
    22. +
    23. - @number_sequence ||= user.acceptable_number_sequences.sample +
    24. -
    25. - +
    26. + 1 - end + def call
    27. -
    28. - +
    29. + 2 - + return if wallet_exists?("user_id", user_id)
    30. -
    31. - +
    32. + 2 - def symbol_sequence + create_wallet
    33. -
    34. +
    35. - @symbol_sequence ||= user.acceptable_symbol_sequences.sample + end
    36. -
    37. +
    38. - end +
    39. -
    40. - +
    41. + 1 - + private
    42. -
    43. - +
    44. + 1 - def generate_transaction_id_list + attr_reader :user_id
    45. -
    46. +
    47. - transactions.map(&:id) +
    48. -
    49. - +
    50. + 1 - end + def create_wallet
    51. -
    52. - +
    53. + 2 - + Wallet.create(user_id: user_id) ? true : false
    54. -
    55. +
    56. - def shuffled_string + end
    57. -
    58. +
    59. - puts "Word: #{word}" + end
    60. +
    +
    +
    + + +
    +
    +

    app/services/transaction_to_block_service.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 35 relevant lines. + 35 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - puts "Number sequence: #{number_sequence}" + # frozen_string_literal: true
    3. -
    4. +
    5. - puts "Symbol sequence: #{symbol_sequence}" +
    6. -
    7. - +
    8. + 1 - (word + number_sequence + symbol_sequence).split("").shuffle.join + class TransactionToBlockService < ApplicationService
    9. -
    10. - +
    11. + 1 - end + def initialize(receiver_key, sender_key, amount, block_id)
    12. -
    13. - +
    14. + 3 - + @receiver_key = receiver_key
    15. -
    16. - +
    17. + 3 - def generate_user_acceptable_hash + @sender_key = sender_key
    18. -
    19. - +
    20. + 3 - puts "Shuffled string: #{shuffled_string}" + @amount = amount
    21. -
    22. - +
    23. + 3 - hash = Digest::SHA256.hexdigest(shuffled_string) + @block_id = block_id
    24. -
    25. +
    26. - block_hash = Digest::SHA256.hexdigest(@transactions.to_json) + end
    27. -
    28. +
    29. - master_hash = Digest::SHA256.hexdigest(hash + block_hash) +
    30. -
    31. - +
    32. + 1 - [hash, block_hash, master_hash] + def call
    33. -
    34. - +
    35. + 3 - end + create_transaction_to_block
    36. -
    37. +
    38. - + end
    39. -
    40. +
    41. - def update_block_connections +
    42. -
    43. - +
    44. + 1 - block.update(connections: (block.connections + 1)) + private
    45. -
    46. - +
    47. + 1 - end + attr_reader :receiver_key, :sender_key, :amount, :block_id
    48. -
    49. +
    50. @@ -16869,128 +16659,128 @@

    51. -
    52. - +
    53. + 1 - def ticket_created? + def create_transaction_to_block
    54. -
    55. - +
    56. + 4 - hash, block_hash, master_hash = generate_user_acceptable_hash + return false unless wallets_present?
    57. -
    58. - +
    59. + 3 - @ticket = Ticket.new(user_id: user_id, status: :active, pool_id: pool_id, + unless block_confirmed?
    60. -
    61. - +
    62. + 2 - time_ref: time_ref, user_acceptable_hash: hash, + transaction.block_id = block.id
    63. -
    64. - +
    65. + 2 - confirmation_hash: master_hash, block_hash: block_hash, + pool.amount += transaction.fee
    66. -
    67. - +
    68. + 2 - transaction_id_list: generate_transaction_id_list) + pool.save
    69. -
    70. - +
    71. + 2 - @ticket.save ? true : false + transaction_saved?
    72. -
    73. +
    74. - end + else
    75. -
    76. - +
    77. + 1 - + refresh_block
    78. -
    79. - +
    80. + 1 - def ticket_exists? + create_transaction_to_block
    81. -
    82. +
    83. - Ticket.find_by(user_id: user_id, pool_id: pool_id, status: :active).present? + end
    84. -
    85. +
    86. @@ -17001,126 +16791,95 @@

    87. -
    88. +
    89. - end +
    90. -
    -
    -
    - - -
    -
    -

    app/services/create_wallet_service.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 14 relevant lines. - 0 lines covered and - 14 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. - +
    2. + 1 - # frozen_string_literal: true + def block
    3. -
    4. - +
    5. + 11 - + @block ||= Block.find(block_id)
    6. -
    7. +
    8. - class CreateWalletService < ApplicationService + end
    9. -
    10. +
    11. - def initialize(user_id) +
    12. -
    13. - +
    14. + 1 - @user_id = user_id + def pool
    15. -
    16. - +
    17. + 4 - end + block.pool
    18. -
    19. +
    20. - + end
    21. -
    22. +
    23. @@ -17131,84 +16890,84 @@

    24. -
    25. - +
    26. + 1 - def call + def fee
    27. -
    28. - +
    29. + 2 - return if wallet_exists?("user_id", user_id) + (amount.to_f * 0.10).round(2)
    30. -
    31. +
    32. - create_wallet + end
    33. -
    34. +
    35. - end +
    36. -
    37. - +
    38. + 1 - + def transaction
    39. -
    40. - +
    41. + 6 - private + @transaction ||= Transaction.new(receiver_key: receiver_key, sender_key: sender_key, amount: amount, block_id: block.id, fee: fee)
    42. -
    43. +
    44. - attr_reader :user_id + end
    45. -
    46. +
    47. @@ -17219,29 +16978,29 @@

    48. -
    49. - +
    50. + 1 - def create_wallet + def block_confirmed?
    51. -
    52. - +
    53. + 3 - Wallet.create(user_id: user_id) ? true : false + block.master_hash.present?
    54. -
    55. +
    56. @@ -17252,192 +17011,192 @@

    57. -
    58. +
    59. - end +
    60. -
    -
    -
    - - -
    -
    -

    app/services/transaction_to_block_service.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 49 relevant lines. - 0 lines covered and - 49 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. - +
    2. + 1 - # frozen_string_literal: true + def transaction_saved?
    3. -
    4. - +
    5. + 2 - + transaction.save ? true : false
    6. -
    7. +
    8. - class TransactionToBlockService < ApplicationService + end
    9. -
    10. +
    11. - def initialize(receiver_key, sender_key, amount, block_id) +
    12. -
    13. - +
    14. + 1 - @receiver_key = receiver_key + def wallets_present?
    15. -
    16. - +
    17. + 4 - @sender_key = sender_key + wallet_exists?("pr_key", receiver_key) && wallet_exists?("pv_key", sender_key)
    18. -
    19. +
    20. - @amount = amount + end
    21. -
    22. +
    23. - @block_id = block_id +
    24. -
    25. - +
    26. + 1 - end + def refresh_block
    27. -
    28. - +
    29. + 1 - + @block = Block.where(master_hash: nil).last
    30. -
    31. +
    32. - def call + end
    33. -
    34. +
    35. - create_transaction_to_block + end
    36. +
    +
    +
    + + +
    +
    +

    app/workers/application_worker.rb

    +

    + + 97.62% + + + lines covered +

    + + + +
    + 42 relevant lines. + 41 lines covered and + 1 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - end + # frozen_string_literal: true
    3. -
    4. +
    5. @@ -17448,172 +17207,172 @@

    6. -
    7. - +
    8. + 1 - private + class ApplicationWorker
    9. -
    10. - +
    11. + 1 - attr_reader :receiver_key, :sender_key, :amount, :block_id + include Sidekiq::Worker
    12. -
    13. - +
    14. + 1 - + include ActiveSupport::Rescuable
    15. -
    16. +
    17. - def create_transaction_to_block +
    18. -
    19. - +
    20. + 1 - return false unless wallets_present? + class UserNotFoundError < StandardError
    21. -
    22. - +
    23. + 1 - unless block_confirmed? + def initialize(message = "User not found")
    24. -
    25. - +
    26. + 3 - transaction.block_id = block.id + super
    27. -
    28. +
    29. - pool.amount += transaction.fee + end
    30. -
    31. +
    32. - pool.save + end
    33. -
    34. +
    35. - transaction_saved? +
    36. -
    37. - +
    38. + 1 - else + class WalletNotFoundError < StandardError
    39. -
    40. - +
    41. + 1 - refresh_block + def initialize(message = "Wallet not found")
    42. -
    43. - +
    44. + 1 - create_transaction_to_block + super
    45. -
    46. +
    47. - end + end
    48. -
    49. +
    50. - end + end
    51. -
    52. +
    53. @@ -17624,128 +17383,128 @@

    54. -
    55. - +
    56. + 1 - def block + class AmountNotEnoughError < StandardError
    57. -
    58. - +
    59. + 1 - @block ||= Block.find(block_id) + def initialize(message = "Wallet balance is not enough")
    60. -
    61. - +
    62. + 2 - end + super
    63. -
    64. +
    65. - + end
    66. -
    67. +
    68. - def pool + end
    69. -
    70. +
    71. - block.pool +
    72. -
    73. - +
    74. + 1 - end + class BlockNotFoundError < StandardError
    75. -
    76. - +
    77. + 1 - + def initialize(message = "Block not found")
    78. -
    79. - +
    80. + 1 - def fee + super
    81. -
    82. +
    83. - (amount.to_f * 0.10).round(2) + end
    84. -
    85. +
    86. - end + end
    87. -
    88. +
    89. @@ -17756,84 +17515,84 @@

    90. -
    91. - +
    92. + 1 - def transaction + class PoolNotFoundError < StandardError
    93. -
    94. - +
    95. + 1 - @transaction ||= Transaction.new(receiver_key: receiver_key, sender_key: sender_key, amount: amount, block_id: block.id, fee: fee) + def initialize(message = "Pool not found")
    96. -
    97. - +
    98. + 2 - end + super
    99. -
    100. +
    101. - + end
    102. -
    103. +
    104. - def block_confirmed? + end
    105. -
    106. +
    107. - block.master_hash.present? +
    108. -
    109. - +
    110. + 1 - end + ERRORS = [UserNotFoundError, WalletNotFoundError, AmountNotEnoughError, BlockNotFoundError].freeze
    111. -
    112. +
    113. @@ -17844,181 +17603,150 @@

    114. -
    115. - +
    116. + 1 - def transaction_saved? + ERRORS.each do |error|
    117. -
    118. - +
    119. + 4 - transaction.save ? true : false + rescue_from error do |e|
    120. -
    121. - +
    122. + 1 - end + dev_error(e)
    123. -
    124. +
    125. - + end
    126. -
    127. +
    128. - def wallets_present? + end
    129. -
    130. +
    131. - wallet_exists?("pr_key", receiver_key) && wallet_exists?("pv_key", sender_key) +
    132. -
    133. - +
    134. + 1 - end + def perform
    135. -
    136. - +
    137. + 1 - + raise NotImplementedError
    138. -
    139. +
    140. - def refresh_block + end
    141. -
    142. +
    143. - @block = Block.where(master_hash: nil).last +
    144. -
    145. - +
    146. + 1 - end + def success?
    147. -
    148. - +
    149. + 3 - end + @success ||= false
    150. -
    -
    -
    - - -
    -
    -

    app/workers/application_worker.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 65 relevant lines. - 0 lines covered and - 65 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true + end
    3. -
    4. +
    5. @@ -18029,172 +17757,172 @@

    6. -
    7. - +
    8. + 1 - class ApplicationWorker + private
    9. -
    10. - +
    11. + 1 - include Sidekiq::Worker + def dev_error(e)
    12. -
    13. - +
    14. + 1 - include ActiveSupport::Rescuable + if env_acceptable?
    15. -
    16. - +
    17. + 1 - + puts "#{e.class}: #{e.message}"
    18. -
    19. - +
    20. + 1 - class UserNotFoundError < StandardError + puts e.backtrace
    21. -
    22. +
    23. - def initialize(message = "User not found") + end
    24. -
    25. +
    26. - super + end
    27. -
    28. +
    29. - end +
    30. -
    31. - +
    32. + 1 - end + def user_exists?
    33. -
    34. - +
    35. + 2 - + User.find_by(id: user_id).present?
    36. -
    37. +
    38. - class WalletNotFoundError < StandardError + end
    39. -
    40. +
    41. - def initialize(message = "Wallet not found") +
    42. -
    43. - +
    44. + 1 - super + def pool_exists?
    45. -
    46. +
    47. - end + Pool.find_by(id: pool_id).present?
    48. -
    49. +
    50. - end + end
    51. -
    52. +
    53. @@ -18205,62 +17933,62 @@

    54. -
    55. - +
    56. + 1 - class AmountNotEnoughError < StandardError + def block_exists?
    57. -
    58. - +
    59. + 5 - def initialize(message = "Wallet balance is not enough") + Block.find_by(id: block_id).present?
    60. -
    61. +
    62. - super + rescue NameError
    63. -
    64. - +
    65. + 1 - end + false
    66. -
    67. +
    68. - end + end
    69. -
    70. +
    71. @@ -18271,436 +17999,498 @@

    72. -
    73. - +
    74. + 1 - class BlockNotFoundError < StandardError + def wallet_exists?(method, key)
    75. -
    76. - +
    77. + 10 - def initialize(message = "Block not found") + Wallet.find_by(method => key).present?
    78. -
    79. +
    80. - super + end
    81. -
    82. +
    83. - end +
    84. -
    85. - +
    86. + 1 - end + def env_acceptable?
    87. -
    88. - +
    89. + 1 - + Rails.env.development? || Rails.env.test?
    90. -
    91. +
    92. - class PoolNotFoundError < StandardError + end
    93. -
    94. +
    95. - def initialize(message = "Pool not found") + end
    96. +
    +
    +
    + + +
    +
    +

    app/workers/assign_contract_worker.rb

    +

    + + 57.14% + + + lines covered +

    + + + +
    + 14 relevant lines. + 8 lines covered and + 6 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - super + # frozen_string_literal: true
    3. -
    4. +
    5. - end +
    6. -
    7. - +
    8. + 1 - end + class AssignContractWorker < ApplicationWorker
    9. -
    10. - +
    11. + 1 - + def perform(ticket_id)
    12. -
    13. +
    14. - ERRORS = [UserNotFoundError, WalletNotFoundError, AmountNotEnoughError, BlockNotFoundError].freeze + @ticket_id = ticket_id
    15. -
    16. +
    17. - + assign_contract
    18. -
    19. +
    20. - ERRORS.each do |error| + end
    21. -
    22. +
    23. - rescue_from error do |e| +
    24. -
    25. - +
    26. + 1 - dev_error(e) + private
    27. -
    28. - +
    29. + 1 - end + attr_reader :ticket_id
    30. -
    31. +
    32. - end +
    33. -
    34. - +
    35. + 1 - + def ticket
    36. -
    37. +
    38. - def perform + @ticket ||= Ticket.find_by(id: ticket_id)
    39. -
    40. +
    41. - raise NotImplementedError + end
    42. -
    43. +
    44. - end +
    45. -
    46. - +
    47. + 1 - + def transactions
    48. -
    49. +
    50. - def success? + @transactions ||= Transaction.where(id: ticket.transaction_id_list)
    51. -
    52. +
    53. - @success ||= false + end
    54. -
    55. +
    56. - end +
    57. -
    58. - +
    59. + 1 - + def contracts
    60. -
    61. +
    62. - private + @contracts ||= Contract.where(transaction_id: transactions.pluck(:id))
    63. -
    64. +
    65. - def dev_error(e) + end
    66. -
    67. +
    68. - if env_acceptable? +
    69. -
    70. - +
    71. + 1 - puts "#{e.class}: #{e.message}" + def assign_contract
    72. -
    73. +
    74. - puts e.backtrace + AssignContractsService.new(contracts.pluck(:id), ticket_id).call
    75. -
    76. +
    77. - end + end
    78. -
    79. +
    80. - end + end
    81. +
    +
    +
    + + +
    +
    +

    app/workers/create_ticket_worker.rb

    +

    + + 0.0% + + + lines covered +

    + + + +
    + 18 relevant lines. + 0 lines covered and + 18 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - + # frozen_string_literal: true
    3. -
    4. +
    5. - def user_exists? +
    6. -
    7. +
    8. - User.find_by(id: user_id).present? + class CreateTicketWorker < ApplicationWorker
    9. -
    10. +
    11. - end + sidekiq_options retry: false
    12. -
    13. +
    14. @@ -18711,95 +18501,95 @@

    15. -
    16. +
    17. - def pool_exists? + def perform(user_id, pool_id, time_ref)
    18. -
    19. +
    20. - Pool.find_by(id: pool_id).present? + @user_id = user_id
    21. -
    22. +
    23. - end + @pool_id = pool_id
    24. -
    25. +
    26. - + @time_ref = time_ref
    27. -
    28. +
    29. - def block_exists? + raise UserNotFoundError unless user_exists?
    30. -
    31. +
    32. - Block.find_by(id: block_id).present? + raise PoolNotFoundError unless pool_exists?
    33. -
    34. +
    35. - rescue NameError + if create_ticket
    36. -
    37. +
    38. - false + @success = true
    39. -
    40. +
    41. @@ -18810,51 +18600,51 @@

    42. -
    43. +
    44. - + end
    45. -
    46. +
    47. - def wallet_exists?(method, key) +
    48. -
    49. +
    50. - Wallet.find_by(method => key).present? + private
    51. -
    52. +
    53. - end + attr_reader :user_id, :pool_id, :time_ref
    54. -
    55. +
    56. @@ -18865,29 +18655,29 @@

    57. -
    58. +
    59. - def env_acceptable? + def create_ticket
    60. -
    61. +
    62. - Rails.env.development? || Rails.env.test? + CreateTicketService.new(user_id, pool_id, time_ref).call
    63. -
    64. +
    65. @@ -18898,7 +18688,7 @@

    66. -
    67. +
    68. @@ -18913,12 +18703,12 @@

    69. -
      +
      -

      app/workers/assign_contract_worker.rb

      +

      app/workers/create_wallet_worker.rb

      - - 0.0% + + 100.0% lines covered @@ -18927,9 +18717,9 @@

      - 20 relevant lines. - 0 lines covered and - 20 lines missed. + 11 relevant lines. + 11 lines covered and + 0 lines missed.
      @@ -18962,62 +18752,7 @@

      -
    70. - - - - - - class AssignContractWorker < ApplicationWorker -
    71. -
      - -
      -
    72. - - - - - - def perform(ticket_id) -
    73. -
      - -
      -
    74. - - - - - - @ticket_id = ticket_id -
    75. -
      - -
      -
    76. - - - - - - assign_contract -
    77. -
      - -
      -
    78. - - - - - - end -
    79. -
      - -
      -
    80. +
    81. @@ -19028,29 +18763,29 @@

    82. -
    83. - +
    84. + 1 - private + class CreateWalletWorker < ApplicationWorker
    85. -
    86. - +
    87. + 1 - attr_reader :ticket_id + sidekiq_options retry: false
    88. -
    89. +
    90. @@ -19061,73 +18796,62 @@

    91. -
    92. - - - - - - def ticket -
    93. -
      - -
      -
    94. - +
    95. + 1 - @ticket ||= Ticket.find_by(id: ticket_id) + def perform(user_id)
    96. -
    97. - +
    98. + 2 - end + @user_id = user_id
    99. -
    100. - +
    101. + 2 - + raise UserNotFindError unless user_exists?
    102. -
    103. - +
    104. + 1 - def transactions + if create_wallet
    105. -
    106. - +
    107. + 1 - @transactions ||= Transaction.where(id: ticket.transaction_id_list) + @success = true
    108. -
    109. +
    110. @@ -19138,51 +18862,51 @@

    111. -
    112. +
    113. - + end
    114. -
    115. +
    116. - def contracts +
    117. -
    118. - +
    119. + 1 - @contracts ||= Contract.where(transaction_id: transactions.pluck(:id)) + private
    120. -
    121. - +
    122. + 1 - end + attr_reader :user_id
    123. -
    124. +
    125. @@ -19193,29 +18917,29 @@

    126. -
    127. - +
    128. + 1 - def assign_contract + def create_wallet
    129. -
    130. - +
    131. + 1 - AssignContractsService.new(contracts.pluck(:id), ticket_id).call + CreateWalletService.new(user_id).call
    132. -
    133. +
    134. @@ -19226,7 +18950,7 @@

    135. -
    136. +
    137. @@ -19241,12 +18965,12 @@

    138. -
      +
      -

      app/workers/create_ticket_worker.rb

      +

      app/workers/transaction_to_block_worker.rb

      - - 0.0% + + 100.0% lines covered @@ -19255,9 +18979,9 @@

      - 18 relevant lines. - 0 lines covered and - 18 lines missed. + 29 relevant lines. + 29 lines covered and + 0 lines missed.
      @@ -19290,19 +19014,19 @@

      -
    139. - +
    140. + 1 - class CreateTicketWorker < ApplicationWorker + class TransactionToBlockWorker < ApplicationWorker
    141. -
    142. - +
    143. + 1 @@ -19323,112 +19047,112 @@

    144. -
    145. - +
    146. + 1 - def perform(user_id, pool_id, time_ref) + def perform(receiver_key, sender_key, amount, block_id)
    147. -
    148. - +
    149. + 5 - @user_id = user_id + @receiver_key = receiver_key
    150. -
    151. - +
    152. + 5 - @pool_id = pool_id + @sender_key = sender_key
    153. -
    154. - +
    155. + 5 - @time_ref = time_ref + @amount = amount
    156. -
    157. - +
    158. + 5 - raise UserNotFoundError unless user_exists? + @block_id = block_id
    159. -
    160. - +
    161. + 5 - raise PoolNotFoundError unless pool_exists? + transaction_accepted?
    162. -
    163. +
    164. - if create_ticket + end
    165. -
    166. +
    167. - @success = true +
    168. -
    169. - +
    170. + 1 - end + private
    171. -
    172. - +
    173. + 1 - end + attr_reader :receiver_key, :sender_key, :amount, :block_id
    174. @@ -19444,62 +19168,95 @@

      -
    175. - +
    176. + 1 - private + def transaction_accepted?
    177. -
    178. +
    179. + 5 + + + + raise WalletNotFoundError unless wallets_present? +
    180. +
      + +
      +
    181. + 4 - attr_reader :user_id, :pool_id, :time_ref + raise BlockNotFoundError unless block_exists?
    182. -
    183. +
    184. + 3 + + + + raise AmountNotEnoughError unless amount_check +
    185. +
      + +
      +
    186. + 1 - + subtract_amount
    187. -
    188. +
    189. + 1 + + + + if add_trasaction_to_block +
    190. +
      + +
      +
    191. + 1 - def create_ticket + @success = true
    192. -
    193. +
    194. - CreateTicketService.new(user_id, pool_id, time_ref).call + end
    195. -
    196. +
    197. @@ -19510,71 +19267,51 @@

    198. -
    199. +
    200. - end +
    201. -
    -
    -
    - - -
    -
    -

    app/workers/create_wallet_worker.rb

    -

    - - 0.0% - - - lines covered -

    - - - -
    - 15 relevant lines. - 0 lines covered and - 15 lines missed. -
    - - +
    +
  • + 1 + -
  • + -
    -    
      + def fee + +
    -
  • - +
  • + 4 - # frozen_string_literal: true + (amount.to_f * 0.10).round(2)
  • -
  • +
  • - + end
  • -
  • +
  • @@ -19585,150 +19322,150 @@

  • -
  • - +
  • + 1 - class CreateWalletWorker < ApplicationWorker + def subtract_amount
  • -
  • - +
  • + 1 - sidekiq_options retry: false + @sender_wallet.balance -= amount.to_f + fee
  • -
  • - +
  • + 1 - + @sender_wallet.save
  • -
  • +
  • - def perform(user_id) + end
  • -
  • +
  • - @user_id = user_id +
  • -
  • - +
  • + 1 - raise UserNotFindError unless user_exists? + def wallets_present?
  • -
    -
  • - +
    +
  • + 5 - if create_wallet + wallet_exists?("pr_key", receiver_key) && wallet_exists?("pv_key", sender_key)
  • -
  • +
  • - @success = true + end
  • -
  • +
  • - end +
  • -
  • - +
  • + 1 - end + def amount_check
  • -
  • - +
  • + 3 - + @sender_wallet = Wallet.find_by(pv_key: sender_key)
  • -
  • - +
  • + 3 - private + @sender_wallet.balance >= amount.to_f + fee
  • -
  • +
  • - attr_reader :user_id + end
  • -
  • +
  • @@ -19739,29 +19476,29 @@

  • -
  • - +
  • + 1 - def create_wallet + def add_trasaction_to_block
  • -
  • - +
  • + 1 - CreateWalletService.new(user_id).call + TransactionToBlockService.new(receiver_key, sender_key, amount, block_id).call
  • -
  • +
  • @@ -19772,7 +19509,7 @@

  • -
  • +
  • @@ -19787,12 +19524,12 @@

  • -
    +
    -

    app/workers/transaction_to_block_worker.rb

    +

    lib/osbc/osbc.rb

    - - 0.0% + + 100.0% lines covered @@ -19801,9 +19538,9 @@

    - 38 relevant lines. - 0 lines covered and - 38 lines missed. + 4 relevant lines. + 4 lines covered and + 0 lines missed.
    @@ -19836,117 +19573,148 @@

    -
  • - +
  • + 1 - class TransactionToBlockWorker < ApplicationWorker + module Osbc
  • -
  • - +
  • + 1 - sidekiq_options retry: false + VERSION = "0.1.3"
  • -
  • - +
  • + 1 - + class Osbc
  • -
  • +
  • - def perform(receiver_key, sender_key, amount, block_id) + end
  • -
  • +
  • - @receiver_key = receiver_key +
  • -
  • - +
  • + 1 - @sender_key = sender_key + class Error < StandardError; end
  • -
  • +
  • - @amount = amount + end
  • + + +
    + + +
    +
    +

    lib/outerspace/blockchain.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 4 relevant lines. + 4 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - @block_id = block_id + # frozen_string_literal: true
    3. -
    4. +
    5. - transaction_accepted? +
    6. -
    7. - +
    8. + 1 - end + require_relative "blockchain/version"
    9. -
    10. +
    11. @@ -19957,183 +19725,245 @@

    12. -
    13. - +
    14. + 1 - private + module Outerspace
    15. -
    16. - +
    17. + 1 - attr_reader :receiver_key, :sender_key, :amount, :block_id + module Blockchain
    18. -
    19. - +
    20. + 1 - + class Error < StandardError; end
    21. -
    22. +
    23. - def transaction_accepted? + # Your code goes here...
    24. -
    25. +
    26. - raise WalletNotFoundError unless wallets_present? + end
    27. -
    28. +
    29. - raise BlockNotFoundError unless block_exists? + end
    30. +
    +
    +
    + + +
    +
    +

    lib/outerspace/blockchain/version.rb

    +

    + + 100.0% + + + lines covered +

    + + + +
    + 3 relevant lines. + 3 lines covered and + 0 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - raise AmountNotEnoughError unless amount_check + # frozen_string_literal: true
    3. -
    4. +
    5. - subtract_amount +
    6. -
    7. - +
    8. + 1 - if add_trasaction_to_block + module Outerspace
    9. -
    10. - +
    11. + 1 - @success = true + module Blockchain
    12. -
    13. - +
    14. + 1 - end + VERSION = "0.1.1"
    15. -
    16. +
    17. - end + end
    18. -
    19. +
    20. - + end
    21. +
    +
    +
    + + +
    +
    +

    lib/tasks/task_helpers/compose_taskhelper.rb

    +

    + + 92.31% + + + lines covered +

    + + + +
    + 13 relevant lines. + 12 lines covered and + 1 lines missed. +
    + + + +
    + +
    +    
      +
      -
    1. +
    2. - def fee + # frozen_string_literal: true
    3. -
    4. +
    5. - (amount.to_f * 0.10).round(2) +
    6. -
    7. - +
    8. + 1 - end + require_relative "taskhelper"
    9. -
    10. +
    11. @@ -20144,183 +19974,183 @@

    12. -
    13. +
    14. - def subtract_amount +
    15. -
    16. - +
    17. + 1 - @sender_wallet.balance -= amount.to_f + fee + class TaskHelpers::ComposeTaskhelper < TaskHelpers::Taskhelper
    18. -
    19. - +
    20. + 1 - @sender_wallet.save + def compose_command
    21. -
    22. - +
    23. + 1 - end + @compose_comand ||= compose_command_finder
    24. -
    25. +
    26. - + end
    27. -
    28. +
    29. - def wallets_present? +
    30. -
    31. - +
    32. + 1 - wallet_exists?("pr_key", receiver_key) && wallet_exists?("pv_key", sender_key) + private
    33. -
    34. - +
    35. + 1 - end + def compose_command_finder
    36. -
    37. - +
    38. + 1 - + @command = ["docker compose", "docker-compose"]
    39. -
    40. - +
    41. + 1 - def amount_check + command_return = ""
    42. -
    43. - +
    44. + 1 - @sender_wallet = Wallet.find_by(pv_key: sender_key) + @command.each do |command|
    45. -
    46. - +
    47. + 2 - @sender_wallet.balance >= amount.to_f + fee + system "#{command} --version > /dev/null 2>&1"
    48. -
    49. - +
    50. + 2 - end + command_return = command if $?.success?
    51. -
    52. +
    53. - + end
    54. -
    55. - +
    56. + 1 - def add_trasaction_to_block + raise ComposeError if command_return.empty?
    57. -
    58. +
    59. - TransactionToBlockService.new(receiver_key, sender_key, amount, block_id).call + command_return
    60. -
    61. +
    62. @@ -20331,7 +20161,7 @@

    63. -
    64. +
    65. @@ -20346,12 +20176,12 @@

    66. -
      +
      -

      lib/osbc/osbc.rb

      +

      lib/tasks/task_helpers/taskhelper.rb

      - - 100.0% + + 66.67% lines covered @@ -20360,9 +20190,9 @@

      - 4 relevant lines. - 4 lines covered and - 0 lines missed. + 12 relevant lines. + 8 lines covered and + 4 lines missed.
      @@ -20401,7 +20231,7 @@

      - module Osbc + module TaskHelpers

      @@ -20412,7 +20242,7 @@

      - VERSION = "0.1.3" + class Taskhelper

      @@ -20423,98 +20253,56 @@

      - class Osbc - -

      - -
      -
    67. - - - - - - end + class ComposeError < StandardError
    68. -
    69. - +
    70. + 1 - + def initialize(message = "Docker Compose is not installed")
    71. -
    72. +
    73. 1 - class Error < StandardError; end + super
    74. -
    75. +
    76. - end + end
    77. -
    -
    -
    - - -
    -
    -

    lib/outerspace/blockchain.rb

    -

    - - 100.0% - - - lines covered -

    - - - -
    - 4 relevant lines. - 4 lines covered and - 0 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true + end
    3. -
    4. +
    5. @@ -20525,137 +20313,84 @@

    6. -
    7. +
    8. 1 - require_relative "blockchain/version" -
    9. -
      - -
      -
    10. - - - - - - + private
    11. -
    12. +
    13. 1 - module Outerspace + def dev_error(e)
    14. -
    15. - 1 - - +
    16. - - module Blockchain -
    17. -
      - -
      -
    18. - 1 - class Error < StandardError; end + if env_acceptable?
    19. -
    20. +
    21. - # Your code goes here... + puts "#{e.class}: #{e.message}"
    22. -
    23. +
    24. - end + puts e.backtrace
    25. -
    26. +
    27. - end + end
    28. -
    -
    -
    - - -
    -
    -

    lib/outerspace/blockchain/version.rb

    -

    - - 100.0% - - - lines covered -

    - - - -
    - 3 relevant lines. - 3 lines covered and - 0 lines missed. -
    - - - -
    - -
    -    
      -
      -
    1. +
    2. - # frozen_string_literal: true + end
    3. -
    4. +
    5. @@ -20666,40 +20401,40 @@

    6. -
    7. +
    8. 1 - module Outerspace + def env_acceptable?
    9. -
    10. - 1 +
    11. + - module Blockchain + Rails.env.development? || Rails.env.test?
    12. -
    13. - 1 +
    14. + - VERSION = "0.1.1" + end
    15. -
    16. +
    17. @@ -20710,7 +20445,7 @@

    18. -
    19. +
    20. diff --git a/lib/tasks/compose.rake b/lib/tasks/compose.rake index 57a3b40..3ba4bfb 100644 --- a/lib/tasks/compose.rake +++ b/lib/tasks/compose.rake @@ -1,19 +1,29 @@ # frozen_string_literal: true require "rake" +require_relative "task_helpers/compose_taskhelper" + + +def task_helper + @task_helper ||= TaskHelpers::ComposeTaskhelper.new +end + +def compose_command + @compose_command ||= task_helper.compose_command +end namespace :compose do task :install do puts "Installing Blockchain and Database Containers" - system "sudo docker compose build" + system "sudo #{compose_command} build" puts "Creating Database" - system "sudo docker compose run --rm web rails db:create" + system "sudo #{compose_command} run --rm web rails db:create" puts "Migrating Database" - system "sudo docker compose run --rm web rails db:migrate" + system "sudo #{compose_command} run --rm web rails db:migrate" puts "Seeding Database" - system "sudo docker compose run --rm web rails db:seed" + system "sudo #{compose_command} run --rm web rails db:seed" puts "Stopping Containers" - system "sudo docker compose down" + system "sudo #{compose_command} down" puts "Installing Blockchain and Database Containers... Done!" puts "This already setup your database with some initial values" puts "Start the containers with command: rake compose:up" @@ -32,57 +42,58 @@ namespace :compose do task :build do puts "Building Compose..." - system "sudo docker compose build" + system "sudo #{compose_command} build" puts "Building Compose... Done!" end task :up do + puts compose_command puts "Running Compose..." - system "sudo docker compose up -d --remove-orphans" + system "sudo #{compose_command} up -d --remove-orphans" puts "Running Compose... Done!" end task :down do puts "Stopping Compose..." - system "sudo docker compose down" + system "sudo #{compose_command} down" puts "Stopping Compose... Done!" end task :db_detach do puts "Running Database Detached..." - system "sudo docker compose up -d db" + system "sudo #{compose_command} up -d db" puts "Running Database Detached... Done!" end task :redis_detach do puts "Running Redis Detached..." - system "sudo docker compose up -d redis" + system "sudo #{compose_command} up -d redis" puts "Running Redis Detached... Done!" end task :back_detach do puts "Running Backend Detached..." - system "sudo docker compose up -d --remove-orphans db redis sidekiq" + system "sudo #{compose_command} up -d --remove-orphans db redis sidekiq" puts "Running Backend Detached... Done!" end task :restart do puts "Restarting Compose..." puts "Stopping Compose..." - system "sudo docker compose down" + system "sudo #{compose_command} down" puts "Stopping Compose... Done!" puts "Running Compose..." - system "sudo docker compose up -d --remove-orphans" + system "sudo #{compose_command} up -d --remove-orphans" puts "Restarting Compose... Done!" end task :clean_all do puts "Cleaning Images..." puts "Stopping Compose..." - system "sudo docker compose down" + system "sudo #{compose_command} down" puts "Stopping Compose... Done!" puts "Removing Compose..." - system "sudo docker compose rm -v" + system "sudo #{compose_command} rm -v" puts "Removing Compose... Done!" puts "Removing Containers..." system "sudo docker rm -f $(sudo docker ps -a -q)" diff --git a/lib/tasks/compose_db.rake b/lib/tasks/compose_db.rake index 2fb2f62..c49efa5 100755 --- a/lib/tasks/compose_db.rake +++ b/lib/tasks/compose_db.rake @@ -1,71 +1,81 @@ # frozen_string_literal: true require "rake" +require_relative "task_helpers/compose_taskhelper" + + +def task_helper + @task_helper ||= TaskHelpers::ComposeTaskhelper.new +end + +def compose_command + @compose_comand ||= task_helper.compose_command +end namespace :compose_db do task :drop do puts "Dropping Database..." - system("sudo docker compose run --rm web rake db:drop") + system "sudo #{compose_command} run --rm web rake db:drop" puts "Dropping Database... Done!" end task :rollback do puts "Rolling Back Database..." - system("sudo docker compose run --rm web rails db:rollback") + system "sudo #{compose_command} run --rm web rails db:rollback" puts "Rolling Back Database... Done!" end task :complete_setup do puts "Setting up Database..." - system("sudo docker compose run --rm web rake db:create") - system("sudo docker compose run --rm web rake db:migrate") - system("sudo docker compose run --rm web rake db:seed") + system "sudo #{compose_command} run --rm web rake db:create" + system "sudo #{compose_command} run --rm web rake db:migrate" + system "sudo #{compose_command} run --rm web rake db:seed" puts "Setting up Database... Done!" end task :setup do puts "Setting up and seeding Database..." - system("sudo docker compose run --rm web rake db:setup") + system "sudo #{compose_command} run --rm web rake db:setup" puts "Setting up and seeding Database... Done!" end task :create do puts "Creating Database..." - system("sudo docker compose run --rm web rake db:create") + system "sudo #{compose_command} run --rm web rake db:create" puts "Creating Database... Done!" end task :migrate do puts "Running Migration..." - system("sudo docker compose run --rm web rake db:migrate") + system "sudo #{compose_command} run --rm web rake db:migrate" puts "Running Migration... Done!" end task :seed do puts "Running Seed..." - system("sudo docker compose run --rm web rake db:seed") + system "sudo #{compose_command} run --rm web rake db:seed" puts "Running Seed... Done!" end task :reset_setup do puts "Resettting Database..." - system("sudo docker compose run --rm web rake db:drop") - system("sudo docker compose run --rm web rake db:setup") + system "sudo #{compose_command} run --rm web rake db:drop" + system "sudo #{compose_command} run --rm web rake db:setup" puts "Resetting up Database... Done!" end task :reset do puts "Resetting Database..." - system("sudo docker compose run --rm web rake db:drop") - system("sudo docker compose run --rm web rake db:create") - system("sudo docker compose run --rm web rake db:migrate") - system("sudo docker compose run --rm web rake db:seed") + system "sudo #{compose_command} run --rm web rake db:drop" + system "sudo #{compose_command} run --rm web rake db:create" + system "sudo #{compose_command} run --rm web rake db:migrate" + system "sudo #{compose_command} run --rm web rake db:seed" puts "Resetting Compose... Done!" end task :force_reset do puts "Running Compose Down" - system("rake compose:down") - system("rake compose_db:reset") + system "rake compose:down" + system "rake compose_db:reset" end end diff --git a/lib/tasks/compose_logs.rake b/lib/tasks/compose_logs.rake index badd97c..312f323 100644 --- a/lib/tasks/compose_logs.rake +++ b/lib/tasks/compose_logs.rake @@ -1,95 +1,105 @@ # frozen_string_literal: true require "rake" +require_relative "task_helpers/compose_taskhelper" + + +def task_helper + @task_helper ||= TaskHelpers::ComposeTaskhelper.new +end + +def compose_command + @compose_comand ||= task_helper.compose_command +end namespace :compose_logs do task :web do puts "Showing Web Logs..." - system "sudo docker compose logs web" + system "sudo #{compose_command} logs web" puts "Showing Web Logs... Done!" end task :db do puts "Showing Database Logs..." - system "sudo docker compose logs db" + system "sudo #{compose_command} logs db" puts "Showing Database Logs... Done!" end task :redis do puts "Showing Redis Logs..." - system "sudo docker compose logs redis" + system "sudo #{compose_command} logs redis" puts "Showing Redis Logs... Done!" end task :sidekiq do puts "Showing Sidekiq Logs..." - system "sudo docker compose logs sidekiq" + system "sudo #{compose_command} logs sidekiq" puts "Showing Sidekiq Logs... Done!" end task :all do puts "Showing All Logs..." - system "sudo docker compose logs" + system "sudo #{compose_command} logs" puts "Showing All Logs... Done!" end task :tail_web do puts "Tailing Web Logs..." - system "sudo docker compose logs -f web" + system "sudo #{compose_command} logs -f web" puts "Tailing Web Logs... Done!" end task :tail_db do puts "Tailing Database Logs..." - system "sudo docker compose logs -f db" + system "sudo #{compose_command} logs -f db" puts "Tailing Database Logs... Done!" end task :tail_redis do puts "Tailing Redis Logs..." - system "sudo docker compose logs -f redis" + system "sudo #{compose_command} logs -f redis" puts "Tailing Redis Logs... Done!" end task :tail_sidekiq do puts "Tailing Sidekiq Logs..." - system "sudo docker compose logs -f sidekiq" + system "sudo #{compose_command} logs -f sidekiq" puts "Tailing Sidekiq Logs... Done!" end task :tail_all do puts "Tailing All Logs..." - system "sudo docker compose logs -f" + system "sudo #{compose_command} logs -f" puts "Tailing All Logs... Done!" end task :follow_web do puts "Following Web Logs..." - system "sudo docker compose logs -f web" + system "sudo #{compose_command} logs -f web" puts "Following Web Logs... Done!" end task :follow_db do puts "Following Database Logs..." - system "sudo docker compose logs -f db" + system "sudo #{compose_command} logs -f db" puts "Following Database Logs... Done!" end task :follow_redis do puts "Following Redis Logs..." - system "sudo docker compose logs -f redis" + system "sudo #{compose_command} logs -f redis" puts "Following Redis Logs... Done!" end task :follow_sidekiq do puts "Following Sidekiq Logs..." - system "sudo docker compose logs -f sidekiq" + system "sudo #{compose_command} logs -f sidekiq" puts "Following Sidekiq Logs... Done!" end task :follow_all do puts "Following All Logs..." - system "sudo docker compose logs -f" + system "sudo #{compose_command} logs -f" puts "Following All Logs... Done!" end end diff --git a/lib/tasks/compose_test.rake b/lib/tasks/compose_test.rake index ff62e55..4bce412 100644 --- a/lib/tasks/compose_test.rake +++ b/lib/tasks/compose_test.rake @@ -1,11 +1,21 @@ # frozen_string_literal: true require "rake" +require_relative "task_helpers/compose_taskhelper" + + +def task_helper + @task_helper ||= TaskHelpers::ComposeTaskhelper.new +end + +def compose_command + @compose_comand ||= task_helper.compose_command +end namespace :compose_test do task :all do puts "Running Test..." - system "sudo docker compose run --rm web bundle exec rspec" + system "sudo #{compose_command} run --rm web bundle exec rspec" puts "Running Test... Done!" end @@ -14,49 +24,49 @@ namespace :compose_test do system "rake compose:clean_all" puts "Cleaning Compose Images... Done!" puts "Running Tests ..." - system "sudo docker compose run --rm web bundle exec rspec" + system "sudo #{compose_command} run --rm web bundle exec rspec" puts "Running Clean Test... Done!" end task :controllers do puts "Running Controllers Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/controllers" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/controllers" puts "Running Controllers Test... Done!" end task :models do puts "Running Models Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/models" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/models" puts "Running Models Test... Done!" end task :requests do puts "Running Requests Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/requests" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/requests" puts "Running Requests Test... Done!" end task :helpers do puts "Running Helpers Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/helpers" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/helpers" puts "Running Helpers Test... Done!" end task :mailers do puts "Running Mailers Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/mailers" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/mailers" puts "Running Mailers Test... Done!" end task :routing do puts "Running Routing Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/routing" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/routing" puts "Running Routing Test... Done!" end task :views do puts "Running Views Test..." - system "sudo docker compose run --rm web bundle exec rspec spec/views" + system "sudo #{compose_command} run --rm web bundle exec rspec spec/views" puts "Running Views Test... Done!" end end diff --git a/lib/tasks/task_helpers/compose_taskhelper.rb b/lib/tasks/task_helpers/compose_taskhelper.rb new file mode 100644 index 0000000..06da3b7 --- /dev/null +++ b/lib/tasks/task_helpers/compose_taskhelper.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require_relative "taskhelper" + + +class TaskHelpers::ComposeTaskhelper < TaskHelpers::Taskhelper + def compose_command + @compose_comand ||= compose_command_finder + end + + private + def compose_command_finder + @command = ["docker compose", "docker-compose"] + command_return = "" + @command.each do |command| + system "#{command} --version > /dev/null 2>&1" + command_return = command if $?.success? + end + raise ComposeError if command_return.empty? + command_return + end +end diff --git a/lib/tasks/task_helpers/taskhelper.rb b/lib/tasks/task_helpers/taskhelper.rb new file mode 100644 index 0000000..eebe25f --- /dev/null +++ b/lib/tasks/task_helpers/taskhelper.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module TaskHelpers + class Taskhelper + class ComposeError < StandardError + def initialize(message = "Docker Compose is not installed") + super + end + end + + private + def dev_error(e) + if env_acceptable? + puts "#{e.class}: #{e.message}" + puts e.backtrace + end + end + + def env_acceptable? + Rails.env.development? || Rails.env.test? + end + end +end diff --git a/osbc.gemspec b/osbc.gemspec index dccc11d..afedcc7 100644 --- a/osbc.gemspec +++ b/osbc.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.metadata["allowed_push_host"] = "https://rubygems.org" spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/outerspace-coding/outerspace-blockchain" + spec.metadata["source_code_uri"] = "https://github.com/JesusGautamah/outerspace-blockchain" spec.metadata["changelog_uri"] = "https://github.com/outerspace-coding/outerspace-blockchain/blob/main/CHANGELOG.md" spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject do |f| diff --git a/spec/factories/tickets.rb b/spec/factories/tickets.rb index f06d3bd..69afbb4 100644 --- a/spec/factories/tickets.rb +++ b/spec/factories/tickets.rb @@ -2,7 +2,7 @@ factory :ticket do user { nil } pool { nil } - status { 1 } + status { "active" } time_ref { "2021-09-01 15:00:00" } end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 13e47ec..fb59a6a 100755 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,6 +7,7 @@ add_group "Workers", "app/workers" add_group "OSBC", "lib/osbc" add_group "Outerspace", "lib/outerspace" + add_group "Task Helpers", "lib/tasks/task_helpers" add_filter "app/channels" add_filter "app/jobs" end diff --git a/spec/requests/api/v1/block_confirmations_spec.rb b/spec/requests/api/v1/block_confirmations_spec.rb new file mode 100644 index 0000000..db499e3 --- /dev/null +++ b/spec/requests/api/v1/block_confirmations_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe Api::V1::BlockConfirmationsController, type: :request do + let(:chain) { create(:chain) } + let(:block) { create(:block, chain: chain) } + let(:sender_user) { create(:user) } + let(:receiver_user) { create(:user, email: "receiver@mail.com", username: "receiver") } + let(:miner_user) { create(:user, email: "miner@mail.com", username: "miner") } + let(:miner_wallet) { create(:wallet, user: miner_user) } + let(:sender_wallet) { create(:wallet, user: sender_user) } + let(:receiver_wallet) { create(:wallet, user: receiver_user) } + let(:transaction) { create(:transaction, sender_key: sender_wallet.pv_key, receiver_key: receiver_wallet.pr_key, block: block) } + let(:s_transaction) { create(:transaction, sender_key: sender_wallet.pv_key, receiver_key: sender_wallet.pr_key, block: block) } + + describe "POST /api/v1/confirm_block" do + context "When user is not founded by X-API-KEY and X-API-SECRET" do + it "returns unauthorized" do + post "/api/v1/confirm_block", params: { user_acceptable_hash: "not provided 4 this test" }, headers: { "X-API-KEY": "invalid", "X-API-SECRET": "invalid" } + expect(response).to have_http_status(:unauthorized) + end + end + + context "When user is founded by X-API-KEY and X-API-SECRET" do + it "returns ticket not found" do + post "/api/v1/confirm_block", params: { user_acceptable_hash: "not provided" }, headers: { "X-API-KEY": sender_user.api_key, "X-API-SECRET": sender_user.api_secret } + expect(response.body).to eq({ error: "Ticket not found" }.to_json) + expect(response).to have_http_status(:not_found) + end + end + + context "When user is founded by X-API-KEY and X-API-SECRET and ticket is founded" do + it "returns confirmation hash not found when invalid param name" do + create(:ticket, pool: block.pool, user: miner_user, user_acceptable_hash: "a" * 64) + post "/api/v1/confirm_block", params: { user_acceptable_hash: "not provided" }, headers: { "X-API-KEY": miner_user.api_key, "X-API-SECRET": miner_user.api_secret } + expect(response.body).to eq({ error: "Confirmation hash not found" }.to_json) + expect(response).to have_http_status(:not_found) + end + + it "returns confirmation hash not found when invalid param value name" do + create(:ticket, pool: block.pool, user: miner_user, user_acceptable_hash: "a" * 62) + post "/api/v1/confirm_block", params: { user_confirmation_hash: "a" * 64 }, headers: { "X-API-KEY": miner_user.api_key, "X-API-SECRET": miner_user.api_secret } + expect(response.body).to eq({ error: "Not valid confirmation hash" }.to_json) + expect(response).to have_http_status(:not_found) + end + end + + context "When user is founded by X-API-KEY and X-API-SECRET and ticket is founded and confirmation hash is valid" do + it "returns contract assigned" do + create(:ticket, pool: block.pool, user: miner_user, user_acceptable_hash: "a" * 64) + post "/api/v1/confirm_block", params: { user_confirmation_hash: "a" * 64 }, headers: { "X-API-KEY": miner_user.api_key, "X-API-SECRET": miner_user.api_secret } + expect(response.body).to eq({ message: "Contract assigned" }.to_json) + expect(response).to have_http_status(:ok) + end + end + end + + describe "GET /apu/v1/info_to_mine" do + context "it return unauthorized if user not founded by X-API-KEY and X-API-SECRET" do + it "returns unauthorized" do + get "/api/v1/info_to_mine", headers: { "X-API-KEY": "invalid" } + expect(response).to have_http_status(:unauthorized) + end + + it "returns unauthorized if user is founded but secret invalid" do + get "/api/v1/info_to_mine", headers: { "X-API-KEY": sender_user.api_key, "X-API-SECRET": "invalid" } + expect(response).to have_http_status(:unauthorized) + end + + it "returns { words , number_sequences, symbol_sequences } if user is founded and secret valid" do + get "/api/v1/info_to_mine", headers: { "X-API-KEY": sender_user.api_key, "X-API-SECRET": sender_user.api_secret } + expect(response.body).to eq({ words: sender_user.acceptable_words, + number_sequences: sender_user.acceptable_number_sequences, + symbol_sequences: sender_user.acceptable_symbol_sequences }.to_json) + expect(response).to have_http_status(:ok) + end + end + end +end diff --git a/spec/tasks/tasks_helpers/compose_taskhelper_spec.rb b/spec/tasks/tasks_helpers/compose_taskhelper_spec.rb new file mode 100644 index 0000000..264e259 --- /dev/null +++ b/spec/tasks/tasks_helpers/compose_taskhelper_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "rails_helper" +require "/myapp/lib/tasks/task_helpers/compose_taskhelper" +require "/myapp/lib/tasks/task_helpers/taskhelper" + +describe TaskHelpers::ComposeTaskhelper do + describe "#compose_command" do + it "returns docker-compose" do + if ENV["ENV_MACHINE"] == "docker" + expect { subject.compose_command }.to raise_error(TaskHelpers::Taskhelper::ComposeError) + end + end + end +end