Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
refactord some tests and created some new tests, added TaskHelper mod…
Browse files Browse the repository at this point in the history
…ule and Taskhelper, ComposeTaskhelper to recognize if dkcer is installed, and if packege or plugin is been used, need some more cases
  • Loading branch information
JesusGautamah committed Nov 24, 2022
1 parent c465500 commit 5fa1139
Show file tree
Hide file tree
Showing 23 changed files with 6,061 additions and 6,340 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ FIRST_CHAIN_MAINTAINER=YOUR_NAME
CONTRACTS_LIMIT=2
SIGNATURES_LIMIT=5
REDIS_URL=redis://redis:6379
ENV_MACHINE=docker
24 changes: 12 additions & 12 deletions app/controllers/api/v1/block_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/contracts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
52 changes: 0 additions & 52 deletions app/controllers/pools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions app/controllers/signatures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 0 additions & 27 deletions app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,13 @@ 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?
create_ticket
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)
Expand Down
3 changes: 1 addition & 2 deletions app/views/transactions/_transaction.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= render "users/shared/error_messages", resource: resource %>
<div class="field text-black">
<%= f.label :username, class: "text-white" %><br />
<em class="text-white">(10 characters minimum)</em>
<em class="text-white">(10 characters minimum)</em><br />
<%= 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" %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion config/routes/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"line": 70.1
"line": 80.9
}
}
Loading

0 comments on commit 5fa1139

Please sign in to comment.